what would the script look like to open a new sheet

D

des-sa

2 questions again
i got it right to give a sheet the same name as the contents of a cell, but
that cell entry is a date formula and it seems that that's not
acceptable...is there a way of entering the date in, say cell E1, then have
the sheet name displayed as that date?

what would the macro look like to duplicate an existing sheet, giving it
today's date as a name - the date would be entered in a cell.
 
T

Tim879

this doesn't do any error checking to ensure there is a date in cell
A1. you can change the A1 to be any reference you want.

Sub AddSheet()
Dim newsheetname As Variant

newsheetname = Year(Range("a1").Value) & "-" &
Month(Range("a1").Value) & "-" & Day(Range("a1").Value)

Worksheets.Add().Name = newsheetname

End Sub
 

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

Top