On Error Goto Label Does not work

abi_learn_vba

Board Regular
Joined
Nov 6, 2009
Messages
215
Hi,

In my code i have provided an Error Handler for a type mismatch, but still my code stops at the point shows "Run time Error 13". Can any one say why is it happening so?

Code:
    On Error GoTo ck2
    myval = Int(Cells(fr, 2))
For 
'
'
'
'Loop

ck2:
'My code continues from here if there is an Error.

Any help would be appreciated.

Cheers..
-Abi
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Perhaps

Code:
If IsError(Cells(fr, 2)) Then GoTo ck2


before trying the conversion, although this will become complex if you could have multiple error values.
 
Upvote 0
Thanks for you reply VoG,

I am still getting the same error after using the code you suggested. Also i need to mention here that, "Int(Cells(Fr,0))" is referring to a Date format. If they are not in Date format this code would produce a type mismatch error which i would like to use the error handler to resume from ck2.

Code:
If IsError(Int(Cells(fr, 2))) Then GoTo ck2
myval = Int(Cells(fr, 2))
For 
'
'
'
'Loop

ck2:
'My code continue
 
Upvote 0
Maybe:
Code:
If Not IsDate(Cells(Fr,2)) Then GoTo ck2
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

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