excel vba select multiple ranges code example
Example: excel vba select multiple ranges
Sub ClearRanges()
' Using the Range Property
Worksheets("Sheet1").Range("C5:D9,G9:H16,B14:D18").ClearContents
Range("MyRange, YourRange, HisRange").ClearContents
' Using the Union Method
Dim myMultipleRange As Range
Set myMultipleRange = Union(Sheets("Sheet1").Range("A1:B2"), _
Sheets("Sheet1").Range("C3:D4"))
myMultipleRange.ClearContents
End Sub