I can't figure out this Run time Error 13 Type Mismatch

vbaNumpty

Board Regular
Joined
Apr 20, 2021
Messages
171
Office Version
  1. 365
Platform
  1. Windows
My code is pretty simple in terms of what I am doing, but I get a mismatch error despite the variable being shown to equal one of my conditions. Code is below:

VBA Code:
Private Sub CoverBox_Change()

    Dim ptCvr As Variant
    Dim pkSize As Variant
    Dim ptCheck As Variant
    
    ptCheck = Left(Me.CoverBox.Value, 7)
    
    Me.PackSizeBox.Value = ""
    
    If Me.CoverBox.Value = "" Then
        pkSize = Evaluate("=FILTER(PackSize[Pack Size],PackSize[Product ID]= """ & Me.PID.Value & ""","""")")
        Me.PackSizeBox.List = pkSize
        Exit Sub
    End If
    
    If Me.CoverBox.Value = "Self-Watering" Then
        pkSize = Evaluate("=FILTER(SelfWaterPk[Pack Size],SelfWaterPk[Product ID]= """ & Me.PID.Value & ""","""")")
        Me.PackSizeBox.List = pkSize
        Exit Sub
    End If

    If ptCheck = "Ceramic" Then
        pkSize = Evaluate("=FILTER(CeramicPk[Pack Size],CeramicPk[Product ID]= """ & Me.PID.Value & ""","""")")
        Me.PackSizeBox.List = pkSize
        Exit Sub
    End If
    
    If ptCheck = "Soft Po" Or "Hard Po" Then
        pkSize = Evaluate("=FILTER(HrdSftCover[Pack Size],HrdSftCover[Product ID]= """ & Me.PID.Value & ""","""")")
        Me.PackSizeBox.List = pkSize
        Exit Sub
    End If
    
    If Me.CoverBox.Value = "Tea Collection" Then
        pkSize = Evaluate("=FILTER(TeaPk[Pack Size],TeaPk[Product ID]= """ & Me.PID.Value & ""","""")")
        Me.PackSizeBox.List = pkSize
        Exit Sub
    End If

End Sub

The line

If ptCheck = "Soft Po" Or "Hard Po" Then

is giving me the type mismatch which I am having a hard time figuring out, because the other instace of

If ptCheck = "Ceramic" Then

Works fine, and by my estimation these two lines are doing the exact same thing. What am I missing here?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
It needs to be
VBA Code:
 If ptCheck = "Soft Po" Or ptCheck = "Hard Po" Then
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top