![]() |
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 |
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 |
All times are GMT +1. The time now is 12:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com