'ボタンがクリックされた時の処理 Private Sub CommandButton1_Click() '変数宣言 Dim i As String 'セルA1の値を変数に入れる i = Range("A1").Value 'ファンクションのAnsに変数 i の値を渡す If ans(i) = False Then MsgBox ("空白はだめです") Exit Sub End If End Sub '変数 i の値を受け取り処理する Function ans(i) As Boolean '空白ならば If i = "" Then '戻り値の変数としてFalseを返す ans = False Else ans = True End If 'ここまできたら上に戻る End Function |