?
Solved

Vlookup + format

Posted on 2012-03-15
4
Medium Priority
?
237 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
[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
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 81

Accepted Solution

by:
byundt earned 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
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…
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

764 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