Problem with "INDIRECT()" within VBA EVALUATE function

cgcamal

Active Member
Joined
May 2, 2007
Messages
472
Hi to all,

I'm using a great formula that returns the position of last number within a text string, the formula I get it from
http://www.mrexcel.com/forum/showthread.php?t=367606 and is as follow.


Code:
=MATCH(10^99,INDEX(--MID(A1,ROW(INDIRECT(""1:""&LEN(A1))),1),0))
When is entered in a cell is works correctly, but I receive error 2023 when I tried to use it within
EVALUATE() in VBA.

It looks the problem is when the part in red is evaluated.

Code:
Sub LastNum_In_String()
LN= Evaluate("MATCH(10^99,INDEX(--MID(A2,ROW([B][COLOR=Red]INDIRECT(""1:""&LEN(A2))[/COLOR][/B]),1),0))")
End Sub
Any ideas in how to solve this?

I'm not sure if the same result (get position of the last number) could be obtained without using "INDIRECT" function.

Many thanks in advance

Regards
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
One way:

Code:
    Dim iLen As Long
    iLen = Len(Range("A2").Value)
    LN = Evaluate("=MATCH(2^15, --MID(A2, ROW(1:" & iLen & "), 1))")
 
Last edited:
Upvote 0
Or ...

Code:
    LN = Evaluate("=MATCH(2^15, --MID(A2, ROW(1:" & Len([a2]) & "), 1))")
 
Upvote 0
Great shg,

It works correctly and is now smaller too, without using 2 functions.

Really thanks for your help and time.

Best regards
 
Upvote 0
You're welcome, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

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