Execute code on a range of cells, then move down and do again?
Found another solution:
Dim sh As Worksheet
Set sh = ActiveSheet
Dim rng1 As Range
Set rng1 = sh.Range("B9")
Dim rng As Range
Set rng =
sh.Range("b9:b21,f9:f21,q9:q21,a20:c21,d20:e20,g20 :r21,g12:r12,g15:p16,r15,h13:i14,j14:k14,a10:e10,g 9,c19")
Line1:
rng.ClearContents
Set rng = rng.Offset(15, 0)
Set rng1 = rng1.Offset(15, 0)
If rng1 = "0" Then
GoTo Line1
Else
End If
too easy!
Thx your message got me thinking which led to this.
learning is fun.............
"JLGWhiz" wrote:
There are other ways to do it, but for the description you gave, this should
cover it.
Sub clrCont()
Dim sh As Worksheet
sh = ActiveSheet
sh.Range("B9:B19").ClearContents
sh.Range("F9:F21").ClearContents
sh.Range("A20:C21").ClearContents
If sh.Range("B24").Value = 0 Then
sh.Range("B24:B35").ClearContents
sh.Range("F24:F37").ClearContents
sh.Range("A38:C39").ClearContents
End If
End Sub
"BABs" wrote:
I have the following code to clear a range of cells. Now I need it to move
down 15 rows and do it again, what do I need to add in to the code?
Range ( _"B9:B21,F9:F21,A20:C21,C19"_ ).Select
Range ("C19") . Activate
Selection.ClearContents
IF Range ("B9" + 15) = 0 THEN
'do again for the cells starting from B9+15
ELSE
End IF
End Sub
TIA
|