Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Formatting Macro

Posted on 2011-02-17
3
Medium Priority
?
309 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

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

618 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