Jon EvanCook
New Member
- Joined
- Sep 30, 2019
- Messages
- 11
I have a large worksheet used for creating daily reports on a monthly basis. I am trying to create a macro that will clear the data entries in order to create a blank worksheet that can be used as a template.
The workbook contains a lot of pages but the ones that are currently giving me a problem are the 31 daily entry sheets(one for each day of the month). The sheet codes are Sheet1 through 31, and the sheet names are "1" through "31"
I want to select each sheet, clear the contents of multiple ranges and then in 3 cells I want to insert some text. The code I am currently using is below this clears the multiple ranges but the following 3 lines which add text to 3 cells only work on the first page selected leaving these fields blank on the following 30 pages.
I have tried using a For/Next loop to cycle through the 31 pages but this requires the sheet names to be created as a variable of the loop index, when it selects Sheet1 it actually selects the first sheet in the workbook and not the sheet with the sheetname id = Sheet1 (the tab Name is "1") so this method does not act on the correct sheets.
Is there a more efficient way to clear these ranges and add the three text cells and then park the cursor in cell B8?
Many thanks
Jon
The workbook contains a lot of pages but the ones that are currently giving me a problem are the 31 daily entry sheets(one for each day of the month). The sheet codes are Sheet1 through 31, and the sheet names are "1" through "31"
I want to select each sheet, clear the contents of multiple ranges and then in 3 cells I want to insert some text. The code I am currently using is below this clears the multiple ranges but the following 3 lines which add text to 3 cells only work on the first page selected leaving these fields blank on the following 30 pages.
I have tried using a For/Next loop to cycle through the 31 pages but this requires the sheet names to be created as a variable of the loop index, when it selects Sheet1 it actually selects the first sheet in the workbook and not the sheet with the sheetname id = Sheet1 (the tab Name is "1") so this method does not act on the correct sheets.
Is there a more efficient way to clear these ranges and add the three text cells and then park the cursor in cell B8?
Code:
' Clean out all entries in DRS to create a Virgin copy - Screen updating disabled
Sheets(Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", _
"16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31")).Select
Range("$B$8:$C$48,$F$8:$O$48,$E$66:$E$72,$C$75:$C$77,$H$66:$H$74,$H$76:$H$77,$C$101:$M$113,$C$115:$M$117,$C$119:$M121,$C$123:$M$127,$U$8:$AM$48").Select
Selection.ClearContents
Range("$C$119").Value = "Today:"
Range("$C$120").Value = "Forecast:"
Range("$C$121").Value = "Outlook:"
Range("$B$8").Select
Many thanks
Jon