Hi all, I want to clear a dynamic range of non-contiguous cells. The code I'm using (or trying to use ) is:
I'm getting a syntax error on the "set nRange" line. I tried a lot of variations, including .cells, range.cells, etc. How would I clear the data in these cells...?
Code:
Dim sht1 As Worksheet
Dim LastRowWS1 As Long
Dim nRange As Range
Set sht1 = Sheets("Data")
LastRowWS1 = sht1.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Set nRange = Range("A" & LastRowWS1 - 1), ("A" & LastRowWS1 - 3), ("B" & LastRowWS1 - 1), ("B" & LastRowWS1 - 3), _
("C" & LastRowWS1 - 1), ("C" & LastRowWS1 - 3), ("D" & LastRowWS1 - 1), ("D" & LastRowWS1 - 2), ("D" & LastRowWS1 - 3), _
("E" & LastRowWS1 - 1), ("E" & LastRowWS1 - 2), ("E" & LastRowWS1 - 3)
With nRange
.Locked = False
.ClearContents
End With