macro not working !!!

paquirl

Board Regular
Joined
Oct 12, 2010
Messages
226
Office Version
  1. 2016
Platform
  1. Windows
this macro is supposed to highlight rows that meet certain criteria in one of three columns. it is not highlighting all the rows in the third column. :(

Sub paquirl3()
' ABSOLUTEHIGHLIGHTED Macro
' Macro recorded 3/10/2011 by Andrew Quirl
'
' Keyboard Shortcut: Ctrl+Shift+U
'
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
Rows("4:4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=7, Criteria1:=">=5 to 6 weeks", Operator:= _
xlAnd
Range("A5:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.ColorIndex = 6
Range("A5:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.Pattern = xlSolid
Selection.AutoFilter Field:=7
Selection.AutoFilter Field:=25, Criteria1:=">(35) Active", Operator:= _
xlAnd
Range("A405:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.ColorIndex = 6
Range("A405:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.Pattern = xlSolid
Selection.AutoFilter Field:=25
Selection.AutoFilter Field:=38, Criteria1:="Yes"
Range("A1026:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.ColorIndex = 6
Range("A1026:A" & lr).EntireRow.SpecialCells(xlCellTypeVisible).Interior.Pattern = xlSolid
Selection.AutoFilter Field:=38
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Do you mean it's not highlighting all the "Yes" rows?

Maybe try changing this...
Code:
lr = Cells(Rows.Count, 1).End(xlUp).Row
Not always the most reliable method to get the last used row depending on how your data is structured. If column A doesn't have an entry in the last used row then it may not be accurate.


To this...
Code:
lr = Cells.Find("*", [A1], xlFormulas, , xlByRows, xlPrevious).Row

Also, your code will only highlight "Yes" rows within rows 1026 to Lr
 
Last edited:
Upvote 0
i made the change and it is still missing a bunch of the "yes" rows.

additionally, i'm wondering if i need to also adjust something to make it know to highlight ALL the rows that show up when a filter is applied. this is because the report is different from week to week. one week the report may be quite long and another week it may be short. if i recorded the macro when it was short, it may not highlight all the rows it needs to when the report has more data on it. what do you think?
 
Upvote 0
well what i'm trying to do with this macro is:

1. autofilter all the columns
2. choose a column and filter by criteria chosen >=5 to 6 weeks
3. highlight all rows that meet this criteria
4. unfilter this column to "show all" again
5. filter another column by criteria chosen >(35) Active
6. highlight all rows that meet this criteria
7. unfilter this column to "show all" again
8. filter another column by criteria chosen YES
9. highlight all rows that meet this criterion
10. unfilter this column to "show all" again
 
Upvote 0
i think you did it - you rock!

would you give me your email to keep in my contact list?

-Andrew
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top