| 
    
     |  | こんばんわ。はじめまして。 
 フォーム上のテキストボックスを3つ作ります。
 オブジェクト名をテキスト名前、テキスト住所、テキスト電話番号にしてます。
 
 登録というコマンドボタンを押すと
 「登録していいですか?」というメッセージボックスを表示させて
 「OK」「キャンセル」と出るように作りたいです。
 
 ただ、「OK」だけだと分かるのですが、「キャンセル」の入れ方が分かりません。
 今のコードは下記のようにしています。
 
 また、例えば名前が空欄なら「名前が記入されていません」というエラーメッセージがでて
 「OK」を押すと入力画面に戻るようなものも3つそれぞれ作りたいと思っています。
 これはIF構文を応用すればいいのかと思っているんですが、なかなかうまくいきません。
 よろしければ、加えてご教授願います。
 
 
 Private Sub 登録_Click()
 
 MsgBox "登録していいですか?"
 
 Range("a65536").End(xlUp).Offset(1).Select
 Selection = テキスト名前
 With Selection.Borders(xlEdgeLeft)      '外枠左罫線
 .LineStyle = xlContinuous
 .Weight = xlThin
 End With
 With Selection.Borders(xlEdgeBottom)     '外枠下罫線
 .LineStyle = xlContinuous
 .Weight = xlThin
 End With
 With Selection.Borders(xlEdgeRight)      '外枠右罫線
 LineStyle = xlContinuous
 .Weight = xlThin
 End With
 Selection.Offset(, 1) = テキスト住所
 Range("a65536").End(xlUp).Offset(, 1).Select
 With Selection.Borders(xlEdgeBottom)     '外枠下罫線
 .LineStyle = xlContinuous
 .Weight = xlThin
 End With
 With Selection.Borders(xlEdgeRight)      '外枠右罫線
 LineStyle = xlContinuous
 .Weight = xlThin
 End With
 Selection.Offset(, 1) = テキスト電話番号
 Range("a65536").End(xlUp).Offset(, 2).Select
 With Selection.Borders(xlEdgeBottom)     '外枠下罫線
 .LineStyle = xlContinuous
 .Weight = xlThin
 End With
 With Selection.Borders(xlEdgeRight)      '外枠右罫線
 LineStyle = xlContinuous
 .Weight = xlThin
 End With
 
 テキスト名前 = ""
 テキスト住所 = ""
 テキスト電話番号 = ""
 テキスト名前.SetFocus
 
 End Sub
 
 |  |