Removing forward slash from date using vba

litestream

Active Member
Joined
Jul 24, 2006
Messages
323
When I use:

If TextBox1.Value > 0 Then
TextBox2.Text = (7 * Val(TextBox1.Text)) + DateSerial(Year(Date), 1, 1) - 9
End If
End Sub

It returns a date in the format "16/7/2008" which is fine for the display in text box 2, but how can I convert this to "160708" format so that I can include it in my file name?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try:

Code:
Private Sub TextBox1_Change()
    If TextBox1.Value > 0 Then
        TextBox2.Text = Format((7 * Val(TextBox1.Text)) + DateSerial(Year(Date), 1, 1) - 9, "ddmmyy")
    End If
End Sub
 
Upvote 0
Andrew, I believe OP wanted to keep slashes for TB presentation but remove for purposes of use within filename.
 
Upvote 0

Forum statistics

Threads
1,214,381
Messages
6,119,192
Members
448,874
Latest member
Lancelots

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