PDA

View Full Version : Solved: Looping based on a condition



Aussiebear
12-09-2011, 10:59 PM
I have a named range SO_Fish (Standards!D2:G12) which lists 10 targeted fish. I need to loop through each cell in the range (Standards!D2:D12) where the points allocated (Standards!G2:G12) are greater than zero and add their names to the column header starting at cell Results!C2. How can I do this?

Bob Phillips
12-10-2011, 04:01 AM
Sub GrabFish()
Dim cell As Range
Dim col As Long
col = 3
With Worksheets("Standards").Range("SO_Fish")
For Each cell In .Columns(4).Cells
If cell.Value > 0 Then
Worksheets("Results").Cells(1, col).Value = cell.Offset(0, -3).Value
col = col + 1
End If
Next cell
End With
End Sub

Aussiebear
12-10-2011, 02:38 PM
Thank you