?
Solved

Formatting Macro

Posted on 2011-02-17
3
Medium Priority
?
306 Views
Last Modified: 2012-06-21
Hello
I need a macro that will filter on a field and highlight cells that have a value greater that 0 for specific cells. I have attached an example.  In the example the macro need to do the following:
1.Filter on the field titled "Paid", where the field "Paid" = Yes.  
2.Highlight the cells in blue where the values in the cells are greater than 0 for the columns with the titles (G1,G3,G5,G7)

Thanks
Test.xlsm
0
Comment
Question by:Thomask23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Expert Comment

by:KnutsonBM
ID: 34917174
This should do the trick:

Sub FilterAndHilight()

    ActiveSheet.Range("$A:$L").AutoFilter Field:=4, Criteria1:="Yes"
    m = 8
    Do Until Cells(m, 1).Value = ""
        If Cells(m, 5).Value > 0 Then
            Cells(m, 5).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .ThemeColor = xlThemeColorAccent1
                    .TintAndShade = 0.399975585192419
                    .PatternTintAndShade = 0
                End With
        Else
        End If
           If Cells(m, 7).Value > 0 Then
            Cells(m, 7).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .ThemeColor = xlThemeColorAccent1
                    .TintAndShade = 0.399975585192419
                    .PatternTintAndShade = 0
                End With
        Else
        End If
        If Cells(m, 9).Value > 0 Then
            Cells(m, 9).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .ThemeColor = xlThemeColorAccent1
                    .TintAndShade = 0.399975585192419
                    .PatternTintAndShade = 0
                End With
        Else
        End If
        If Cells(m, 11).Value > 0 Then
            Cells(m, 11).Select
                With Selection.Interior
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .ThemeColor = xlThemeColorAccent1
                    .TintAndShade = 0.399975585192419
                    .PatternTintAndShade = 0
                End With
        Else
        End If
        m = m + 1
    Loop
End Sub
0
 

Author Comment

by:Thomask23
ID: 34917804
Thanks...this is really good. This almost works.
However I have vlookups in each cell.  I need to highlight cells that have a value returned from the vlookup > 0.

Thanks again for your help.
0
 
LVL 6

Accepted Solution

by:
KnutsonBM earned 2000 total points
ID: 34917865
which cells are your v-lookups in?  I opened up your sample sheet and do not see any formulas.  have you considered using Conditional Formatting?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question