S
Sam via OfficeKB.com
Hi All,
I would like VBA code to find the last occurrence of zero ("0") per row
starting in column "K" to "Q". There could be more than one zero in a row.
Once the last occurrence of zero is found per row, I then need to use
autofilter to filter the column(s) containing the last zero occurrence.
My numeric data spans 7 columns and many rows: starts in column "K", row 21.
Can the code below be modified to find instead the last occurrence of zero
per row and then use autofilter to filter the column(s) containing the last
zero occurrence.
Your help is most appreciated.
The code below worked ok to find and filter the last cell / row in each
column with a zero value:
Frange is last cell / row in column
nCol is column
afField is autofilter field
Dim Frange As Range
Dim nCol As Integer
Dim afField As Integer
nCol = 0
afField = 11
Set Frange = Range("K21").Offset(0, nCol).End(xlDown)
Do Until nCol = 7
If Frange = 0 Then
Selection.AutoFilter Field:=afField, Criteria1:=Frange.Value
End If
nCol = nCol + 1
afField = afField + 1
Set Frange = Range("K21").Offset(0, nCol).End(xlDown)
Loop
Thank you,
Sam
I would like VBA code to find the last occurrence of zero ("0") per row
starting in column "K" to "Q". There could be more than one zero in a row.
Once the last occurrence of zero is found per row, I then need to use
autofilter to filter the column(s) containing the last zero occurrence.
My numeric data spans 7 columns and many rows: starts in column "K", row 21.
Can the code below be modified to find instead the last occurrence of zero
per row and then use autofilter to filter the column(s) containing the last
zero occurrence.
Your help is most appreciated.
The code below worked ok to find and filter the last cell / row in each
column with a zero value:
Frange is last cell / row in column
nCol is column
afField is autofilter field
Dim Frange As Range
Dim nCol As Integer
Dim afField As Integer
nCol = 0
afField = 11
Set Frange = Range("K21").Offset(0, nCol).End(xlDown)
Do Until nCol = 7
If Frange = 0 Then
Selection.AutoFilter Field:=afField, Criteria1:=Frange.Value
End If
nCol = nCol + 1
afField = afField + 1
Set Frange = Range("K21").Offset(0, nCol).End(xlDown)
Loop
Thank you,
Sam