Extracting last numbers in string

JoeS01

Well-known Member
Joined
Jun 25, 2005
Messages
832
I am looking for VBA code to help me extract the RH numbers after the slash, if it exists, and would appreciate any help:

10/15/20 >> 20
10/12 >> 12
6 >>6
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Joe

One way. Assumes that the data is in the range A1:A3. This will have to be adjusted.

Code:
Sub ccc()
 For Each ce In Range("a1:a3")
  slashh = Len(ce) - Len(WorksheetFunction.Substitute(ce, "/", ""))
  If slashh > 0 Then
   ce.Offset(0, 1).Value = Right(ce, Len(ce) - WorksheetFunction.Search("~~", WorksheetFunction.Substitute(ce, "/", "~", slashh), 1))
  Else
   ce.Offset(0, 1).Value = ce
  End If
 Next ce
End Sub


Tony
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,020
Members
449,480
Latest member
yesitisasport

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