A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
This code:-
Worksheets("Lists").Range("B2:C2,B3:C3,B6:C6").Clear
- will only clear the named ranges of the Worksheet called Lists and nothing else.
This code:-
ActiveSheet.Range("B2:C2,B3:C3,B6:C6").ClearContents
- will clear the named ranges of the Active Sheet (i.e. the only one that’s currently selected by the user) so it can apply to multiple Worksheets.
For this part:-
Activating the sheet always works:
Sub ClearSummaryDataAll()
ActiveSheet.Range("B2:C2,B3:C3,B6:C6").ClearContents
End Sub
- you’re not activating the Worksheet but referring to the currently selected Worksheet (can you see the difference?) and this is why this code’ll apply to the named ranges of the Active Sheet.