custom cell date format

welkin

New Member
Joined
Jun 15, 2008
Messages
7
i'm trying to get excel macro to enter the title of my excel with the title + date on a cell.

The date on the cell is in ddmmyy (custom) format. e.g. 130608

I put in the follow:

ActiveWorkbook.Names.Add name:="cobdate", RefersToR1C1:= _
"=R2C4"

Dim date As String

date = Range("titledate")

Range("A2").Value = "title" & date

however, after running the macro, the result is "title 13/06/08".

how do i get the macro to use the date as 130608 without the slashes?

I need to do away with the slashes because after this I have another macro to save the file using the title, which slashes are not permitted in filenames.

Anyone have any good suggestions pls?

Thanks in advance.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
First thing I would recommend is not using date as a variable.

Date is a VBA function/statement that returns the current date.

If you want to format a date without the slashs take a look at the Format function.

By the way your post is rather confusing.

You originally refer to creating a named range, cobdate, but then you appear to refer to a named range called titledate.:eek:
 
Upvote 0
I agree with Norie - use MyDate or similar and

Code:
Range("A2").Value = "title " & Format(MyDate, "ddmmyy")
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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