Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop only Visible Cells

Status
Not open for further replies.

NewUserMo

Technical User
Mar 15, 2015
23
US
I am not sure how to manipulate the following code to loop through visible cells. I currently have a filter, but the For loop is checking every cell instead of visible (filtered data):

lRow = ActiveCell.Row
For lRow = LasrRowMax To 2 Step -1
If Cells(lRow, "DP").Value = "YES" Or Cells(lRow, "DP").Value = "NO" Then

Cells(lRow, "DJ").Value = Cells(lRow, "DP").Value

End If
Next
 
hi,

Code:
'
   lRow = ActiveCell.Row
   For lRow = LasrRowMax To 2 Step -1
      If Rows(lRow).Hidden = False then
         Select Case Cells(lRow, "DP").Value 
            Case "Yes", "No"
               Cells(lRow, "DJ").Value = Cells(lRow, "DP").Value
         End Select
      End If
   Next
 
Just curious...
Why the first line of code: [tt]lRow = ActiveCell.Row[/tt] ?
The [tt]lRow[/tt] gets new value(s) in For loop in the second line of code anyway


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top