View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RompStar RompStar is offline
external usenet poster
 
Posts: 29
Default help with highlight code

I am having a problem, this code is supposed to select using
autofilter a blank in column 29 and an "X" in column 34, which it
does. The problem is that sometimes there are no row values left
after these 2 autofilter conditions and it puts a value of 3 and
highlights all the ROWS outside of the .autofilter condition and I
just want it to do that on the rows that survive and not rows that are
outside of these 2 conditions in the worksheet.

How do I tell this code to only highlight the color and the value of 3
into rows that survive the autofilter seletions or skip it if there
are no values ?

Thank you.



With Range("A6:AH" & lr)
On Error Resume Next

.AutoFilter Field:=29, Criteria1:="=", Operator:=xlAnd
.AutoFilter Field:=34, Criteria1:="X"

.Sort Key1:=Range("C7"), Order1:=xlAscending, Key2:=Range( _
"D7"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Range("AI7:AI" & lr).Value = 3

Range("A7:AH" & lr).Select
With Selection.Interior
.ColorIndex = 36 ' light yellow
.Pattern = xlSolid
End With

.AutoFilter

End With