![]() |
looping through a range
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 |
looping through a range
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 -------------------------------------------------------------------------------------------------------------- Be advised to back up your WorkBook before attempting to make changes. -------------------------------------------------------------------------------------------------------------- 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 |
All times are GMT +1. The time now is 02:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com