Solved

Vlookup + format

Posted on 2012-03-15
4
229 Views
Last Modified: 2012-03-16
Hi,

I have attached a WB.

I would like some vb code to hightlight rows red or green in the ASPA tab dependant on whether or not their Sedol is present in the tab "Phoenix"

So comparing Col A in ASPA against Col B in Phoenix

I have manually highlighted a few lines that would be green and would be red after the code has run

Thanks
Seamus
ASPAMatch.zip
0
Comment
Question by:Seamus2626
  • 2
4 Comments
 
LVL 15

Expert Comment

by:CSLARSEN
ID: 37724500
Hi
I guess you wouldnt even need code, just a slightly more advanced conditional formatting.

E.g. like this

cheers
cslarsen
ASPAMatch.xlsx
0
 

Author Comment

by:Seamus2626
ID: 37724652
Hi,

Where is the conditional formatting stored? I cant see it anywhere?

Thanks
Seamus
0
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 37727487
Conditional formatting is stored with the worksheet. Depending on the version of Excel, you may need to use named ranges to avoid referring to a different worksheet--Conditional Formatting didn't permit direct references to other worksheets before Excel 2010 (I believe).

Here is a macro that works in Excel 2003 and 2010. It creates a named range for Phoenix worksheet column B, then applies conditional formatting to ASPA worksheet data.
Sub SedolConditionalFormatting()
Dim nm As Name
Dim rg As Range
Application.ScreenUpdating = False
On Error Resume Next
Set nm = ThisWorkbook.Names("PhoenixSedol")
On Error GoTo 0
If nm Is Nothing Then
    ThisWorkbook.Names.Add "PhoenixSedol", RefersTo:="=Phoenix!$B:$B"
End If
Set rg = Worksheets("ASPA").Range("A1").CurrentRegion
Set rg = rg.Offset(1, 0).Resize(rg.Rows.Count - 1)
With rg
    .FormatConditions.Delete
    .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($A2<>"""",COUNTIF(PhoenixSedol,$A2)>0)"
    .FormatConditions(1).Interior.ColorIndex = 4
    .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($A2<>"""",COUNTIF(PhoenixSedol,$A2)=0)"
    .FormatConditions(2).Interior.ColorIndex = 3
End With
End Sub

Open in new window

0
 

Author Closing Comment

by:Seamus2626
ID: 37728821
Thank you!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now