ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   what would the script look like to open a new sheet (https://www.excelbanter.com/excel-discussion-misc-queries/195091-what-would-script-look-like-open-new-sheet.html)

des-sa[_2_]

what would the script look like to open a new sheet
 
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.

Tim879

what would the script look like to open a new sheet
 
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


On Jul 16, 12:32*pm, des-sa wrote:
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. *




All times are GMT +1. The time now is 11:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com