I created a macro to copy my current (2018) sheet to end of workbook & unprotect the new sheet. More on that later. Then I run HideSomeRowsAndColumns on the new sheet. It works, but does not stop after the last entry in column D. It appears to run all the way to the max number of rows possible in Excel (65,000+?). That's not a major problem, because the final results are correct. I can tell because it takes much longer than expected to run (for < 400 rows) and by the formatting of columns A&B in the empty rows at the bottom of the output. Col AC is not formatted.
My sheet has formatted columns, including borders and (color) fill. This was done by selecting columns & formatting. That, of course, extends far beyond the number of rows that I use. Actually, my sheet is for 1 year only. Each January I copy & setup for the new year, including 2 weeks of the old year . . . that's why rows 4-16 are hidden.
I tried removing the border format for column D to see if that counts as used, but that didn't shorten the run time or change the output. Actually, the run time isn't critical. I can live with that. This procedure will be used relatively infrequently.
My new (recorded) macro . . .
Sub CopyAndUnprotect()
'
' Copy worksheet (to end) and unprotect
'
Sheets("2018").Select
Sheets("2018").Copy After:=Sheets(16)
Sheets("2018 (2)").Select
ActiveSheet.Unprotect
'
Application.Run "HideSomeRowsAndColumns"
End Sub
How do I replace "2018" with [current sheet name] & Sheets(16) with [end of workbook] so I don't have to modify in the future?
Thanks, again, for your help.