Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel macro help
I need help in creating a macro that will compare two columns of text.
Essentially, I need this macro to look at column A and for whatever column A is, to look in column B for an expected answer. If the answer given isn't part of the list of variables, I need a result screen. So if in column A I have the word 'CAR', and the acceptable variables for 'CAR' are "red", "green" and "blue", but in Column B the result is "FORD", I need to have that line highlighted. Sorry if this doesn't make a lot of sense, too little sleep, too much tea! Thanks, Jean |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel macro help
Depends on setting up the Select case, you could do select Cases nested
instead of if statements. Depends on how complicated your data is in actuality. Sub RightInfo() 'Start in column "B" on the first data element to compare to ' "A", will run till it runs out of data Do Until ActiveCell.Value = "" BValue = ActiveCell.Value AValue = ActiveCell.Offset(0, -1).Value Select Case AValue Case "Car" If BValue = "Red" Or BValue = "Green" Then 'Do nothing Else With Selection.Interior .ColorIndex = 36 .Pattern = xlSolid .PatternColorIndex = xlAutomatic End With End If Case Else End Select ActiveCell.Offset(1, 0).Select Loop End Sub Hope this will help. David "Jean D." wrote: I need help in creating a macro that will compare two columns of text. Essentially, I need this macro to look at column A and for whatever column A is, to look in column B for an expected answer. If the answer given isn't part of the list of variables, I need a result screen. So if in column A I have the word 'CAR', and the acceptable variables for 'CAR' are "red", "green" and "blue", but in Column B the result is "FORD", I need to have that line highlighted. Sorry if this doesn't make a lot of sense, too little sleep, too much tea! Thanks, Jean |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
translate lotus 1-2-3 macro into excel macro using excel 2000 | Excel Programming |