Ref error type - VBA

Kavy

Well-known Member
Joined
Jun 25, 2007
Messages
607
Hello all,

My question is Is there any line of code that looks for just "#Ref!" errors?

We have an excel sheet which is a roll-up of other excel workbooks. The workbooks are named after their "epr" number.

If a user enters a epr number, the macro checks the directory for the epr number b4 grabbing data from the sheet.

How it checks the directly is it actually trys to pull data, and if the first peice of data comes back as a "#REF!" then it assumes theres no file.

I was using "Iserror" to check this, but it turns out that line of code also checks for permissions, and that snaged us.

Is there any line of code that looks for just "#Ref!" errors?

I tried "CVErr(xlErrRef)" but I can't seem to figure out the syntax, and help files no help
=ERROR.TYPE(D12) seems to only work in an excel cell not in VBA??

Thank you!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Are you physically looking for a cell with a #REF! error within it? If so, you could use the Find() method of the range object?
 
Upvote 0
Also you can loop through your cells, like:

Code:
Sub RefErr()
Dim r As Range
 
For Each r In Range("A1:A5")
    If IsError(r) Then If r = CVErr(xlErrRef) Then MsgBox "Range " & r.Address & " has a #REF! error."
Next r
End Sub
 
Upvote 0
Thank you both for your replys, the r = CVErr is what I was tryign to figure out!

When my excel cell referances another file which isnt there, it loads a "open" window. In VB is there anyway to turn off that window?

Thank you!
 
Upvote 0

Forum statistics

Threads
1,206,819
Messages
6,075,045
Members
446,115
Latest member
orlamag

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