VBA: Parsing String

iand5

New Member
Joined
Jul 26, 2017
Messages
36
Hi, I currently have the following string in a cell: "09/17/2015 0715"

I am exporting this to a .txt file.

Is it possible to parse the string so that it gets rid of the date and only displays "0715" when exporting the .txt file?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You can extract the 4 last right digits in VBA as you will do it in Excel:

Code:
CellVal = "[COLOR=#333333][FONT=Verdana]09/17/2015 0715"[/FONT][/COLOR]
  RightDigits = Right(CellVal,4)
 
Last edited:
Upvote 0
Thanks!

Is there a way to apply this to a range of rows? Let's say I only want the last 4 digits for Range("A1:A10").
 
Upvote 0
Is there a way to apply this to a range of rows? Let's say I only want the last 4 digits for Range("A1:A10").
Does this do what you want...
Code:
Sub RemoveDatePart()
  Range("A1:A10").NumberFormat = "@"
  Range("A1:A10") = Evaluate("IF({1},RIGHT(A1:A10,4))")
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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