Help with loop-I'm stuck
This is a little different than what you described, but I believe it will do
what you want. Give it a try. You can modify it to suit your propose.
Sub djk()
Dim LastCell As Long, Lastcol As Long
Dim WS As Worksheet
Set WS = ActiveSheet
Lastcol = WS.Cells.Find(What:="*", After:=WS.Range("A5"), _
LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, MatchCase:=False).Column
lstRw = WS.Cells(Rows.Count, "a").End(xlUp).Row
Set rng = WS.Range("B5", WS.Cells(lstRw, Lastcol))
For Each Rw In rng.Rows
If Application.CountA(Range("B" & Rw.Row, _
WS.Cells(Rw.Row, Lastcol))) 0 Then
WS.Cells(Rw.Row, Lastcol).Offset(0, 2) = "Has Value"
Else
WS.Cells(Rw.Row, Lastcol).Offset(0, 2) = "No Value Found"
End If
Next
End Sub
"mattg" wrote in message
...
I am trying to loop through a pivot table to look for values by row. The
number of rows and columns will vary.
Basically, if in Row 5 only one cell from Column B to the last column(not
counting the "Grand Total") is not blank then the column after "Grand
Total"
should say "First Time".
If Columns C and D are not blank the first column after "grand Total"
should
say "Two Times in a Row". etc, etc.
Here's what I have. This is too advanced for me.
Dim LastCell As Range
Dim WS As Worksheet
Set WS = ActiveSheet
Set LastCell = WS.UsedRange.SpecialCells(xlCellTypeLastCell)
Set lastcol = LastCell.Offset(-1, -1)
lstrw = .Cells(Rows.Count, "a").End(xlUp).Row
For myrow = lstrw To 5 Step -1
For Each Row In myrow
If Range("B:" & lastcol).Value 'stuck here
|