For Loop in Filtered List

H

Hafeez Esmail

How do I structure a 'for loop' within a filtered list?

I keep the header row blank, and I want to start from the
second row that contains data (not the first)

++++(*) represents the column letter+++++
for each CELL in FILTERED_LIST
set cell.column(4).formulalocal = "=EXACT(N" &
PREV_CELL.row & ",N" & CURR_CELL.row & ")"
next

The BLOCK letters are what I don't know. When I say
PREV_CELL, I mean the previously visible cell.
I've tried to use the constant XlCellTypeVisible, but that
didn't do much

TIA
Hafeez Esmail
 
H

Hafeez Esmail

The solution I used is so simple, I feel stupid for asking
the question.
Here's the code I'm using...

Call SrtData("D1", "N1", "C1")

'Filter for Stops, then sort (Type, Equip, DateTime)
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Cells.Select
Selection.AutoFilter
Selection.AutoFilter 11, "=*STOP*"

'Get first/last visible cell with data!
intFrstRow = Range("A1").End(xlDown).Row
intLastRow = Range("A" & intFrstRow).End(xlDown).Row

'Check If Equip1 = Equip2
Range("A" & intFrstRow & ":A" & intLastRow).SpecialCells
(xlCellTypeVisible).Select
i = 0
For Each cell In Selection
i = i + 1
If i = 1 Then
intPrevRow = cell.Row
ElseIf i > 1 Then
intCrntRow = cell.Row
cell.Offset(0, 4).FormulaLocal = "=EXACT(N" &
intPrevRow & ", N" & intCrntRow & ")"
If StrComp(cell.Offset(0, 4).Value, "True",
vbTextCompare) = 0 Then
cell.Offset(0, 5).FormulaLocal = "=Exact(D" &
intPrevRow & ",D" & intCrntRow & ")"
If StrComp(cell.Offset(0, 5).Value, "True",
vbTextCompare) = 0 Then
cell.Offset(0, 6).FormulaLocal = "=((C" &
intCrntRow & " - C" & intPrevRow & ") < " & DBL2MIN & ")"
End If
End If
intPrevRow = intCrntRow
Else
'do nothing
End If
Next cell

MsgBox "stop"

Hope this helps anyone looking for an example!
 

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