Type Mismatch error using IF

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
Greetings,

I am receiving a type mismatch error in the code below:

Code:
If Cells(b, "A").Value = "" Then        Rows(b).Delete
        End If

I understand the problem more or less, but am stumped as to find a simple solution.

As I understand it if the property or variable is not of the correct type then its going to cause the mismatch error.

I am receiving the error when the contents of the cell being compared to "" is "#VALUE!"

I would like to be able to filter for any and all types of things without the risk of a mismatch.

Ideally I would be able to write something like:

Code:
If Cells(b, "A").Value = "" or "#VALUE!" or "N/A" Then
Rows(b).Delete
End If
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Code:
If Cells("A" & b).Value = "" Or Cells("A" & b).Value = "#Value" Or Cells("A" & b).Value = "N/A" Then
    Cells("A" & b).EntireRow.Delete
End If
 
Upvote 0
Maybe...

Code:
If IsError(Cells(b, "A")) Then
    'do something
ElseIf Cells(b, "A") = "" Then
    'do something
End If

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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