Help to Get the 4 Digits From Right in Columns See sample details below

JenniferLorca

New Member
Joined
Oct 16, 2013
Messages
2
Now I want to get the 4 Digits highlighted below. Not Including special character like dots etc.
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\167405\167405-2545- JENNIFER YASMIN SILVA M LUZ.JPG
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\167406\167406A2.764
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\171416\photo with 1kb\171416T1.425
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\181278\6156 (2).jpg
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\181278\6156.jpg
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\181278\6174 (2).jpg
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\LAC\BRA\181278\6157.jpg
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\MEE\JWG\174680\6504 AbdElrahman Mohammed Abu Sneyma-1.JPG
C:\Users\sponrmt\Desktop\C05\C05\DVD COPIES\MEE\JWG\174680\6512 Marwa Abu Jarad-1.JPG
C:\Users\sponrmt\Desktop\C05\C05\for uploading\TAI-182955-ZAR\182955-3191_20130606_135330_APR.Zip

<tbody>
</tbody>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Give this UDF (user defined function) a try...

Code:
Function FourDigits(ByVal S As String) As String
  Dim X As Long
  S = "-" & Replace(S, ".", "") & "-"
  For X = Len(S) - 5 To 1 Step -1
    If Mid(S, X, 6) Like "[!0-9]####[!0-9]" Then
      FourDigits = Mid(S, X + 1, 4)
      Exit Function
    End If
  Next
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use FourDigits just like it was a built-in Excel function. For example,

=FourDigits(A1)
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

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