I don't understand the code below, please help.
It keeps on returning a type mismatch error against the variable b.
Dim a As Integer
Dim b As String
a = InputBox("Input the number of items", "Total Number of Items.")
b = InputBox("Which Block?", "Total Number of Items.")
Do While b <> "a" Or "A" Or "B" Or "b"
MsgBox ("Invalid Block. Try again, Input A or B")
b = InputBox("Which Block?", "SELECT BLOCK.")
Loop
If b = "a" Or "A" Then
Me.ComboBox1.List = Worksheets("Sheet1").Range("a3:a39").Value
Else
Me.ComboBox2.List = Worksheets("Sheet2").Range("a3:a35").Value
End If
You can use Application.InputBox to force a text input for a and and numeric input for b
Using UCASE$ shortens your testing
Dim a As Long
Dim b As String
a = Application.InputBox("Input the number of items", "Total Number of Items.", , , , , , 1)
b = Application.InputBox("Which Block?", "Total Number of Items.", , , , , 2)
Do While UCase$(b) <> "A" And UCase$(b) <> "B"
b = Application.InputBox("Which Block?", "Invalid Entry - Total Number of Items.", , , , , 2)
Loop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With