コンボボックスに入力された日付をもとにカレンダーを作成するVBAを作成しています。カレンダーの始まりと終わりの日付を入力するので始まりと終わりが逆に入力された場合にエラーとして処理したいです。現在のコードが下記になります。
論理演算子の使い方があまりわかっていないので教えてください。
ngpで年月日になっています。
Dim n, g, p As String Dim n2, g2, p2 As String Dim h, h2 As String n = ComboBox1.Text g = ComboBox2.Text p = ComboBox3.Text h = n & " / " & g & " / " & p Range("G5").Value = h n2 = ComboBox4.Text g2 = ComboBox5.Text p2 = ComboBox6.Text h2 = n2 & " / " & g2 & " / " & p2 If n > n2 Then MsgBox "正しい日付を入力してください" Unload Me Exit Sub End If If n = n2 And g > g2 Then MsgBox "正しい日付を入力してください" Unload Me Exit Sub End If If n = n2 And g = g2 And p > p2 Then MsgBox "正しい日付を入力してください" Unload Me Exit Sub End If Unload Me
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/08/30 07:12