Using AutoFilter in Excel Macro with Dim LastRow

  • I want the macro to format cells in the worksheet when the value in column A equals "30", "42" or "7". Below is the code I recorded but since my data changes day to day this will not work. I had a macro in the past that worked with the AutoFilter and it was so much more simpler but I lost it. Any help would be appreciated.


  • I could use conditional formatting but I have 3 different criteria that don't work with < than, > than or between because there are multiple range values from 1 to 67. What's wrong with using AutoFilter? I've seen very good vba code that uses the auto filter method.

  • AutoFilter is automatic.


    VBA will not be as efficient as any inbuilt Excel feature.


    You can use the OR Function in Conditional Formatting to have more than one condition.

  • I don't understand the difference between "Automatic" and an inbuilt Excel feature. I would rather have used a solution using AutoFilter but since that seems to be inefficient would you mind showing me how to use OR in the code below for conditional formatting? I need to format cells in column C with values 7, 10, and 42. Thanks!


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!