In VBA, how to strip dashes out of numbers in a variable

mikeburg

Board Regular
Joined
Jun 23, 2005
Messages
165
In my VBA code, how do you strip out dashes, convert numers to a text string, & assign it to a variable from the following?

monthendate=6-30-05

monthendname=monthendate (need the monthendname to be 63005)

Thank so very much.

mikeburg
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I'm not exactly sure what you're doing, but this works for me:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> test()
<SPAN style="color:#00007F">Dim</SPAN> monthenddate <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, monthendname <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>

monthenddate = "6-30-05"

monthendname = Replace(monthenddate, "-", "")

MsgBox monthendname

<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,213,489
Messages
6,113,954
Members
448,535
Latest member
alrossman

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