Trevor3007
Well-known Member
- Joined
- Jan 26, 2017
- Messages
- 675
- Office Version
- 365
- Platform
- Windows
good day ,
I have a workbook with several tabs . I created a macro that will 'blank' applicable cells & then prompt a message to insert a date. below is the code:-
Sub blanksheetsall()
'
' blanksheetsall Macro
'
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
Sheets("Overtime").Select
Range("B9:B15").Select
Selection.ClearContents
Range("C9:C15").Select
Selection.ClearContents
Sheets("Expenses").Select
Range("C6:D12").Select
Selection.ClearContents
Range("E6:E12").Select
Selection.ClearContents
Range("G6").Select
ActiveCell.FormulaR1C1 = "0"
Range("G7").Select
ActiveCell.FormulaR1C1 = "0"
Range("G8").Select
ActiveCell.FormulaR1C1 = "0"
Range("G9").Select
ActiveCell.FormulaR1C1 = "0"
Range("G10").Select
ActiveCell.FormulaR1C1 = "0"
Range("G11").Select
ActiveCell.FormulaR1C1 = "0"
Range("G12").Select
ActiveCell.FormulaR1C1 = "0"
Range("J6").Select
ActiveCell.FormulaR1C1 = "0"
Range("J7").Select
ActiveCell.FormulaR1C1 = "0"
Range("J8").Select
ActiveCell.FormulaR1C1 = "0"
Range("J9").Select
ActiveCell.FormulaR1C1 = "0"
Range("J10").Select
ActiveCell.FormulaR1C1 = "0"
Range("J11").Select
ActiveCell.FormulaR1C1 = ""
Range("J11").Select
ActiveCell.FormulaR1C1 = "0"
Range("J12").Select
ActiveCell.FormulaR1C1 = ""
Range("J12").Select
ActiveCell.FormulaR1C1 = "0"
Range("K6:K12").Select
Selection.ClearContents
Sheets("Quick Calc-For NASA").Select
Range("A6:G11").Select
Selection.ClearContents
Sheets("TMcL-TSheet DXC WC 11-12-2017").Select
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Range("D3").Select
Selection.ClearContents
MsgBox "Enter Applicable WC Date"
End Sub
The above works great until the tab name is changed and the debug highlights the following:-
Sheets("TMcL-TSheet DXC WC 11-12-2017").Select
This is because the file name is changed based on as shown in the tab name "TMcL-TSheet DXC WC 11-12-2017".
How do I get this to run without smoothly?
Many thanks for your all help with my issue.
KR
Trevor3007
I have a workbook with several tabs . I created a macro that will 'blank' applicable cells & then prompt a message to insert a date. below is the code:-
Sub blanksheetsall()
'
' blanksheetsall Macro
'
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 6
Sheets("Overtime").Select
Range("B9:B15").Select
Selection.ClearContents
Range("C9:C15").Select
Selection.ClearContents
Sheets("Expenses").Select
Range("C6:D12").Select
Selection.ClearContents
Range("E6:E12").Select
Selection.ClearContents
Range("G6").Select
ActiveCell.FormulaR1C1 = "0"
Range("G7").Select
ActiveCell.FormulaR1C1 = "0"
Range("G8").Select
ActiveCell.FormulaR1C1 = "0"
Range("G9").Select
ActiveCell.FormulaR1C1 = "0"
Range("G10").Select
ActiveCell.FormulaR1C1 = "0"
Range("G11").Select
ActiveCell.FormulaR1C1 = "0"
Range("G12").Select
ActiveCell.FormulaR1C1 = "0"
Range("J6").Select
ActiveCell.FormulaR1C1 = "0"
Range("J7").Select
ActiveCell.FormulaR1C1 = "0"
Range("J8").Select
ActiveCell.FormulaR1C1 = "0"
Range("J9").Select
ActiveCell.FormulaR1C1 = "0"
Range("J10").Select
ActiveCell.FormulaR1C1 = "0"
Range("J11").Select
ActiveCell.FormulaR1C1 = ""
Range("J11").Select
ActiveCell.FormulaR1C1 = "0"
Range("J12").Select
ActiveCell.FormulaR1C1 = ""
Range("J12").Select
ActiveCell.FormulaR1C1 = "0"
Range("K6:K12").Select
Selection.ClearContents
Sheets("Quick Calc-For NASA").Select
Range("A6:G11").Select
Selection.ClearContents
Sheets("TMcL-TSheet DXC WC 11-12-2017").Select
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
Range("D3").Select
Selection.ClearContents
MsgBox "Enter Applicable WC Date"
End Sub
The above works great until the tab name is changed and the debug highlights the following:-
Sheets("TMcL-TSheet DXC WC 11-12-2017").Select
This is because the file name is changed based on as shown in the tab name "TMcL-TSheet DXC WC 11-12-2017".
How do I get this to run without smoothly?
Many thanks for your all help with my issue.
KR
Trevor3007