use ISError when using a defined name - correct syntax?

jxb

Board Regular
Joined
Apr 19, 2007
Messages
172
Office Version
  1. 2010
Platform
  1. Windows
to all

I rather than hardcoding a column in my vba script I am using a defined name to get the column using
iRefCol=Range("RF1RefCol").Column)
where RF1RefCol is the defined name

this works fine
I now want sto capture the possibility of the define nam enot existing in the xls (deleted by user, name changed, etc)
the following does not seem to work

If IsError(iReFCol = Range("RF1RefCol").Column) then
'do something about it!
end if

Any suggestions/ideas? Thanks

Regards

JXB
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Does this work for you?

Code:
Sub Test()
    Dim iRefCol As Long
    On Error Resume Next
    iRefCol = Range("RF1RefCol").Column
    If Err <> 0 Then
        Err.Clear
        MsgBox "Error"
    Else
        MsgBox "OK"
    End If
    On Error GoTo 0
End Sub
 
Upvote 0
Andrew,

The solution proposed does the job. Thanks a lot

Regards
JXB
 
Upvote 0

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

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