I can't figure out why I keep getting a TYPE MISMATCH error on the line
If TestSel <> "Primary" Or "Secondary" Then
This macro is triggered by clicking a button on a userform called "Printit". The combobox "TestList" has three several entries which the user can choose and the macro acts depending on their selection. The msgbox right before displays the string perfectly every time but it doesn't like the if statement. Thanks.
Sub Printme()
Dim TestSel As String
Dim VlookNum As Single
Dim Qty As Single
Dim Lookup_Range As Range
Dim NoTests As Single
Qty = ActiveSheet.Cells(ActiveCell.Row, 4).Value
TestSel = PrintIt.TestList.Text
MsgBox TestSel
If TestSel <> "Primary" Or "Secondary" Then
MsgBox "Please select a test type"
ElseIf TestSel = "Secondary" Then
VlookNum = 4
Else
VlookNum = 2
End If
Set Lookup_Range = Range("NoSamTab")
NoTests = Application.WorksheetFunction.VLookup(Qty, Lookup_Range, VlookNum, True)
End Sub
Bookmarks