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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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.
I have copied it to all forums where i have asked it.
 
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,214,938
Messages
6,122,346
Members
449,080
Latest member
Armadillos

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