Coding Today's Date In Visual Basic

L

lj

I'm writing some code in Visual Basic and want to to be able to name a
sheet today's date whenever the macro is run? Is there a way to do
this?
 
M

Mark

lj said:
I'm writing some code in Visual Basic and want to to be able to name a
sheet today's date whenever the macro is run? Is there a way to do
this?

if you want to do this you are going to have to remove the "/"'s from
the date. Excel will not allow tham to be part of a worksheet name.
 
B

Bob Phillips

Worksheets.Add.Name = Format(Date,"dd-mmm-yyyy")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

lj

Thanks, is there a way not to hardcode the date into VB but have visual
basic select the current date (similar to the way you can code excel to
display today's date)?
 
B

Bob Phillips

That is what the code does.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top