looping through a range

J

Jo

Hi
I need a bit of help with following code.
I am comparing a list on the sd page, if the value on the
sd page is false I want to clear the contents of a row on
the calc (2) page.
I need help to move the activecell down one each time the
macro runs a loop. Then it should work.
Thanks
Jo

Sheets("sd").Select
Range("ac28:ac37").Name = "sdrange"
For Each cell In Range("sdrange")
Sheets("calc (2)").Select
Range("A9").Select
If cell = False Then
Sheets("calc (2)").Select
ActiveCell.EntireRow.ClearContents
ActiveCell.Offset(1, 0).Select
End If

Next
 
P

pfsardella

If I read your intent correctly, ...................

Sub Tester()

Dim rngCell As Range
Dim rngClear As Range

Sheets("sd").Select
Range("ac28:ac37").Name = "sdrange"
Sheets("calc (2)").Select
Set rngClear = Range("A9")
For Each rngCell In Range("sdrange")
If rngCell.Value = False Then rngClear.EntireRow.ClearContents
Set rngClear = rngClear(2, 1)
Next rngCell

End Sub

Tested using Excel 97SR2 on Windows 98SE,

HTH
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top