Re Name a Worksheet as a Date Format

J

John D O'Connor

Using a Macron how can you rename a Worksheet using a Date format. I have a
Macro that re-names a new Worksheet with whatever Date is in a certain cell,
however the worksheet re-names not in Date format but in numeric format.

Anyone suggest the code that I should insert? My current code is as below

strSheetName = Worksheets(ActiveSheet.Name).Range("a8")

Where A8 is the document date

Thanks

John
 
R

Ron de Bruin

Hi John

Use the Format function

ActiveSheet.Name = Format(Range("B1"), "dd-mm-yy")

ActiveSheet.Name = Format(Now, "dd-mm-yy h-mm-ss")
 
F

Frank Kabel

Hi John
try
strSheetName =
Format(Worksheets(ActiveSheet.Name).Range("a8"),"mmddyyyy")
apply the format code to your needs
 
J

John D O'Connor

Thanks Ron, works a treat

Rgds

John


Ron de Bruin said:
Hi John

Use the Format function

ActiveSheet.Name = Format(Range("B1"), "dd-mm-yy")

ActiveSheet.Name = Format(Now, "dd-mm-yy h-mm-ss")
 
Top