Hey everyone,
I have one large range that I need to split into two smaller ranges, so I was creating two new ranges, setting them equal to a row in the original range, then using the .ClearContents method to empty the new ranges, so I could repopulate them with the data I want.
I slowly commented out code, starting from the bottom up and discovered that
the .ClearContents method, for some reason, would overwrite the first row in the original range with a blank row.
I tried to copy the first row before the code executed the .ClearContents and then add it to the top of the resulting range, but that failed no matter what I tried.
Does anyone know how to empty a range of it's contents without using the .ClearContents method?
Thanks,
Blubber
I have one large range that I need to split into two smaller ranges, so I was creating two new ranges, setting them equal to a row in the original range, then using the .ClearContents method to empty the new ranges, so I could repopulate them with the data I want.
I slowly commented out code, starting from the bottom up and discovered that
the .ClearContents method, for some reason, would overwrite the first row in the original range with a blank row.
I tried to copy the first row before the code executed the .ClearContents and then add it to the top of the resulting range, but that failed no matter what I tried.
Does anyone know how to empty a range of it's contents without using the .ClearContents method?
Code:
If changedate <> Empty Then
Dim MD6800range As range, PS118range As range
Dim MD6800rownum As Long, PS118rownum As Long
Set MD6800range = totalRange(1).EntireRow
Set PS118range = totalRange(1).EntireRow
[COLOR="SeaGreen"] MD6800range.ClearContents
PS118range.ClearContents
[/COLOR]
MD6800rownum = 0
PS118rownum = 0
For I = 1 To rownum
If totalRange(I, 3) < changedate Then
Set MD6800range = Union(MD6800range, totalRange(I, 3).EntireRow)
MD6800rownum = MD6800rownum + 1
End If
If totalRange(I, 3) >= changedate Then
Set PS118range = Union(PS118range, totalRange(I, 3).EntireRow)
PS118rownum = PS118rownum + 1
End If
Next I
Thanks,
Blubber