How to speed up the VBA function

Fixed

Board Regular
Joined
Apr 28, 2017
Messages
95
Hello, friends!

I've wrote some function that reduces the strings by the last symbol:

Code:
Function reducer(ByVal txt As String) As String
txt = Left(txt, InStrRev(Left(txt, Len(txt) - 1), Right(txt, 1)))
reducer = txt
End Function

Example:

AB (function)B (result)
1a+b+c+d+e+f+g+<strike></strike>=reducer(A1)<strike></strike>a+b+c+d+e+f+<strike></strike>
211-22-33-44-55-66-77-<strike></strike>=reducer(A2)<strike></strike>11-22-33-44-55-66-<strike></strike>
311-22-33-44-55-66-<strike></strike>=reducer(A3)<strike></strike>11-22-33-44-55-<strike></strike>
411-22-33-44-55-<strike></strike>=reducer(A4)<strike></strike>11-22-33-44-<strike></strike>
511-22-33-44-<strike></strike>=reducer(A5)<strike></strike>11-22-33-<strike></strike>
611-22-33-<strike></strike>=reducer(A6)<strike></strike>11-22-<strike></strike>
711-22-<strike></strike>=reducer(A7)<strike></strike>11-<strike></strike>
811-<strike></strike>=reducer(A8)<strike></strike>

<tbody>
</tbody>

But it works slow when the number of strings > 100k.
How to speed up this function?

Thank you in advance.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,943
Messages
6,122,376
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