Handling Errors from Match , stored in a variable.

Techikatona

New Member
Joined
Jan 6, 2018
Messages
4
I have looked long for this, but i havent found a truly similar post on web in 2 hours. (so now im posting it on 3 forums)


Scenario:


dim Result as variant
Result = Application.Match(string, Wb.Sheets("UD_Base").Range("UD_Base[U_ID]"), 0)


---
Now if i check the values of -Result- it can either be a number or an error.:
Debug.Print Result -> 1
Debug.Print result -> Error 2042


---
I can test -Result- with: IsError(result) and it gives True or False
... but even if -Result- IS an error, I cannot get its number.


Result.Number -> Object or Type error message comes
so seemingly i cannot use it as in Err.Number


How can I get the error number of -Result- variable?
What is in this case -Result- really equal with?



If i say If Result = ??? Then ... when will it be true if i know that its Error 2042?
I have tested Case "Error 2042" ; Case Err ; Case Error ; Case Err(2042) ; ...
None of these showed True for -Result- when it debug.printed Error 2042


Please enlighten me guys.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Code:
dim Result as String
 Result = Application.Match(string, CSTR(Wb.Sheets("UD_Base").Range("UD_Base[U_ID]")), 0)
Why are U wanting to find out what the error is instead of trying to remove the error? Thanks for the info re. other forums. U really should post links to the other forums. HTH. Dave
ps I think U can get the error number with...
Code:
Msgbox err.number
 
Last edited:
Upvote 0
(so now im posting it on 3 forums)
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
I did provide the link to the answer! See my last post.
Not until after it was solved, and you only posted the one link (you said you posted to three forums), and not until after you got a response here.
All the links should be included in initial post.
 
Upvote 0
Not until after it was solved, and you only posted the one link (you said you posted to three forums), and not until after you got a response here.
All the links should be included in initial post.

Aah, Ok, understood.
Thank you.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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