I have an Excel2007 workbook with several worksheets. Most of the sheets are named with the 4-digit year (2017, 2018, etc).
I recorded a macro to copy a worksheet and then do various things in the new worksheet. I would like to refer to [whichever sheet I'm working in] instead of "2018" & "2018 (2)" shown in the coding below, so that I don't have to have a macro for each year. How do I do that?
Code:Sub CopyAndRenameSheet() Sheets("2018").Select Sheets("2018").Copy Before:=Sheets(1) Sheets("2018 (2)").Select Sheets("2018 (2)").Name = "2018 NewSheetName" Sheets("2018 NewSheetName").Select ActiveSheet.Unprotect (do other stuff . . . ) End Sub




Reply With Quote

Bookmarks