Date addition/format

  • Thread starter Thread starter gjameson via OfficeKB.com
  • Start date Start date
G

gjameson via OfficeKB.com

I have a button on my ss that I want to use to create a new worksheet. The
catch is that I want the name to be a date cell plus 14 days. Here is what I
have so far.

Sub Save_New_Tab_Click()
Worksheets.Add After:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = Format((Range("A2").Value + 14), Date,
"mm_dd_yyyy")

End Sub

A2 has my date in this format mm/dd/yyyy. add 14 days to get worksheet name
in format mm_dd_yyyy. This has been driving me crazy all afternoon. What am I
doing wrong?

TIA
Gerald
 
Sub Save_New_Tab_Click()
Worksheets.Add After:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = Format((Range("A2").Value + 14),
"mm_dd_yyyy")
End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Sorry, that should be

Sub Save_New_Tab_Click()
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = _
Format((Range("A2").Value + 14), "mm_dd_yyyy")
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
What you are doing wrong is giving Format 3 parameters, when it is looking for
only two. Take out the " Date," from your Format function.
 
He is also trying to pick up the date from the wrong sheet.
--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



Fred Smith said:
What you are doing wrong is giving Format 3 parameters, when it is looking
for only two. Take out the " Date," from your Format function.
 
Gentlemen,

Thank you so much for your help. I would have responded sooner, but i was out
sick most of last week. Thanks again for the help.

Gerald

Bob said:
He is also trying to pick up the date from the wrong sheet.
What you are doing wrong is giving Format 3 parameters, when it is looking
for only two. Take out the " Date," from your Format function.
[quoted text clipped - 20 lines]
 

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