Coding Today's Date In Visual Basic

  • Thread starter Thread starter lj
  • Start date Start date
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?
 
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.
 
Worksheets.Add.Name = Format(Date,"dd-mmm-yyyy")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
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)?
 
That is what the code does.

--
HTH

Bob Phillips

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top