Test if Cell range contains error

erock24

Well-known Member
Joined
Oct 26, 2006
Messages
1,163
I'm trying to test if a cell range that has a formula in it shows an error. I've tried this code:

Code:
If BudSht.Range("CheckValue") = Error Then Exit Sub

i'm getting a type mismatch debug, even though the cell range shows to have an 'Error 2023'

is there a way to test if a cell has an error in it in vba?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Could you use a UDF such as:

<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Function</SPAN> HasError(Rng <SPAN style="color:#00007F">As</SPAN> Range) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Boolean</SPAN><br>   <SPAN style="color:#00007F">Dim</SPAN> C <SPAN style="color:#00007F">As</SPAN> Range<br>   <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> C <SPAN style="color:#00007F">In</SPAN> Rng.Cells<br>      <SPAN style="color:#00007F">If</SPAN> Application.WorksheetFunction.IsError(C) <SPAN style="color:#00007F">Then</SPAN> HasError = <SPAN style="color:#00007F">True</SPAN><br>   <SPAN style="color:#00007F">Next</SPAN> C<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN></FONT>
 
Upvote 0
I'm trying to test if a cell range that has a formula in it shows an error. I've tried this code:

Code:
If BudSht.Range("CheckValue") = Error Then Exit Sub
i'm getting a type mismatch debug, even though the cell range shows to have an 'Error 2023'

is there a way to test if a cell has an error in it in vba?
Code:
If IsError(BudSht.Range("CheckValue"))  Then Exit Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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