| 
    
     |  | また、お世話になります。 
 VBAの質問とは違いますが、マクロの自動作成機能で
 
 作成した、マクロに"H列にデータがない場合"はマクロを作動させず、
 
 メッセージボックスに警告を表示させることは可能でしょうか?
 
 以下のマクロです。
 
 Sub 表設定2()
 '
 ' 表設定2 Macro
 ' マクロ記録日 : 2006/3/7 ユーザー名 : 無頼斎
 '
 
 '
 Columns("A:G").Select
 With Selection.Font
 .Name = "MS Pゴシック"
 .Size = 11
 .Strikethrough = False
 .Superscript = False
 .Subscript = False
 .OutlineFont = False
 .Shadow = False
 .Underline = xlUnderlineStyleNone
 .ColorIndex = xlAutomatic
 End With
 Selection.Borders(xlDiagonalDown).LineStyle = xlNone
 Selection.Borders(xlDiagonalUp).LineStyle = xlNone
 With Selection.Borders(xlEdgeLeft)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 With Selection.Borders(xlEdgeTop)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 With Selection.Borders(xlEdgeBottom)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 With Selection.Borders(xlEdgeRight)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 With Selection.Borders(xlInsideVertical)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 With Selection.Borders(xlInsideHorizontal)
 .LineStyle = xlContinuous
 .Weight = xlHairline
 .ColorIndex = xlAutomatic
 End With
 Columns("F:F").Select
 Selection.Insert Shift:=xlToRight
 Range("F1").Select
 ActiveCell.FormulaR1C1 = "個人番号"
 ActiveCell.Characters(1, 2).PhoneticCharacters = "コジン"
 ActiveCell.Characters(3, 2).PhoneticCharacters = "バンゴウ"
 Columns("F:F").Select
 With Selection.Font
 .Name = "MS Pゴシック"
 .Size = 12
 .Strikethrough = False
 .Superscript = False
 .Subscript = False
 .OutlineFont = False
 .Shadow = False
 .Underline = xlUnderlineStyleNone
 .ColorIndex = xlAutomatic
 End With
 Selection.Font.Bold = True
 Range("A1").Select
 With ActiveSheet.PageSetup
 .PrintTitleRows = "$1:$1"
 .PrintTitleColumns = ""
 End With
 ActiveSheet.PageSetup.PrintArea = ""
 With ActiveSheet.PageSetup
 .LeftHeader = ""
 .CenterHeader = "&""MS Pゴシック,太字""&14第1回Toeic受験者名"
 .RightHeader = ""
 .LeftFooter = _
 "&""MS Pゴシック,太字""&14※廊下側から個人番号順に着席して下さい。" & Chr(10) & "※試験免除者の席は詰めて着席して下さい。"
 .CenterFooter = ""
 .RightFooter = ""
 .LeftMargin = Application.InchesToPoints(0.787)
 .RightMargin = Application.InchesToPoints(0.787)
 .TopMargin = Application.InchesToPoints(0.984)
 .BottomMargin = Application.InchesToPoints(0.984)
 .HeaderMargin = Application.InchesToPoints(0.5)
 .FooterMargin = Application.InchesToPoints(0.5)
 .PrintHeadings = False
 .PrintGridlines = False
 .PrintComments = xlPrintNoComments
 .PrintQuality = 600
 .CenterHorizontally = False
 .CenterVertically = False
 .Orientation = xlPortrait
 .Draft = False
 .PaperSize = xlPaperA4
 .FirstPageNumber = xlAutomatic
 .Order = xlDownThenOver
 .BlackAndWhite = False
 .Zoom = 100
 .PrintErrors = xlPrintErrorsDisplayed
 End With
 ActiveWindow.View = xlPageBreakPreview
 ActiveWindow.Zoom = 100
 End Sub
 
 |  |