I have several worksheets in the same Excel file where I need to clear the contents in these specific columns (A,D,G,J,M,P,S & V) starting at row 2 in each column. My worksheets are named (8am, 12pm, 2pm, 4pm and 6pm) - Here is the code so far that clears these contents but it seems like I could add a "For each" statement and ranges in order to streamline this statement and go through each worksheet - any help would be greatly appreciated!
Sub CleanFile()
Dim wsDest As Worksheet
Dim lDestLastRow As Long
Set wsDest = Workbooks("Staffing Bucket Template.xlsm").Worksheets("8am")
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
lDestLastRow2 = wsDest.Cells(wsDest.Rows.Count, "D").End(xlUp).Offset(1).Row
lDestLastRow3 = wsDest.Cells(wsDest.Rows.Count, "G").End(xlUp).Offset(1).Row
lDestLastRow4 = wsDest.Cells(wsDest.Rows.Count, "J").End(xlUp).Offset(1).Row
lDestLastRow5 = wsDest.Cells(wsDest.Rows.Count, "M").End(xlUp).Offset(1).Row
lDestLastRow6 = wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1).Row
lDestLastRow7 = wsDest.Cells(wsDest.Rows.Count, "S").End(xlUp).Offset(1).Row
lDestLastRow8 = wsDest.Cells(wsDest.Rows.Count, "V").End(xlUp).Offset(1).Row
'Clear contents of existing data range
wsDest.Range("A3:A" & lDestLastRow).ClearContents
wsDest.Range("D3:D" & lDestLastRow2).ClearContents
wsDest.Range("G3:G" & lDestLastRow3).ClearContents
wsDest.Range("J3:J" & lDestLastRow4).ClearContents
wsDest.Range("M3:M" & lDestLastRow5).ClearContents
wsDest.Range("P3:P" & lDestLastRow6).ClearContents
wsDest.Range("S3:S" & lDestLastRow7).ClearContents
wsDest.Range("V3:V" & lDestLastRow8).ClearContents
End Sub
Sub CleanFile()
Dim wsDest As Worksheet
Dim lDestLastRow As Long
Set wsDest = Workbooks("Staffing Bucket Template.xlsm").Worksheets("8am")
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
lDestLastRow2 = wsDest.Cells(wsDest.Rows.Count, "D").End(xlUp).Offset(1).Row
lDestLastRow3 = wsDest.Cells(wsDest.Rows.Count, "G").End(xlUp).Offset(1).Row
lDestLastRow4 = wsDest.Cells(wsDest.Rows.Count, "J").End(xlUp).Offset(1).Row
lDestLastRow5 = wsDest.Cells(wsDest.Rows.Count, "M").End(xlUp).Offset(1).Row
lDestLastRow6 = wsDest.Cells(wsDest.Rows.Count, "P").End(xlUp).Offset(1).Row
lDestLastRow7 = wsDest.Cells(wsDest.Rows.Count, "S").End(xlUp).Offset(1).Row
lDestLastRow8 = wsDest.Cells(wsDest.Rows.Count, "V").End(xlUp).Offset(1).Row
'Clear contents of existing data range
wsDest.Range("A3:A" & lDestLastRow).ClearContents
wsDest.Range("D3:D" & lDestLastRow2).ClearContents
wsDest.Range("G3:G" & lDestLastRow3).ClearContents
wsDest.Range("J3:J" & lDestLastRow4).ClearContents
wsDest.Range("M3:M" & lDestLastRow5).ClearContents
wsDest.Range("P3:P" & lDestLastRow6).ClearContents
wsDest.Range("S3:S" & lDestLastRow7).ClearContents
wsDest.Range("V3:V" & lDestLastRow8).ClearContents
End Sub