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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
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,215,660
Messages
6,126,082
Members
449,286
Latest member
Lantern

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