Solved

Formatting Macro

Posted on 2011-02-17
3
304 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

726 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