highlight entire selected range value row

Folks

I have a combo box that selects from values in column A

i.e.

A                               B
British Airways         UK
Qantas                      AUS
Lufthansa                 Germany

If I select from the list in the combo box, how can my macro then highlight the entire selected row in the excel sheet itself based on my choice

so if for example I select Qanta from colum a, both qantas and AUS will be highlighted in
Red
rutgermonsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
samrad1Connect With a Mentor Commented:
Hey!

You can also do this with no VBA and just a CF with a combo box that has a cell link, or VBA that sets a cell value and then lets the CF color the rows. Posting it in case it helps :-)
cf-row-combo.xlsx
0
 
yuppyduCommented:
The combobox is in a form or on a sheet?
0
 
rutgermonsAuthor Commented:
on a sheet

here is the code

Private Sub ComboBox1_gotfocus()
Dim r As Long

r = Sheet1.Range("A1").Offset(Sheet1.Rows.Count - 2, 0).End(xlUp).Row
    With ComboBox1
        .ColumnCount = 2
        .List = Range("A2:B" & r).Value
    End With

End Sub
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
yuppyduCommented:
I have named the upper left cell of the range as StartCell, then add this code:

Dim ItemPosition As Long

Private Sub ComboBox1_Click()
ItemCode = ComboBox1.List(ComboBox1.ListIndex, 1)
Sheet1.Range("StartCell").Offset(ItemCode, 0).Interior.ColorIndex = 36
Sheet1.Range("StartCell").Offset(ItemCode, 1).Interior.ColorIndex = 36
End Sub

Change the color as you wish. Yo can also use RGB and the command becomes .Interior.Color = RGB(200,160,35)
0
 
yuppyduCommented:
Sorry the Dim is: Dim ItemCode as Double
0
 
rutgermonsAuthor Commented:
samrad

can u send me the vba code pls?
0
 
rutgermonsAuthor Commented:
yuppudu,Im struggling wtih ur code,

u declare

Dim ItemPosition As Long



but dont reference it, where does this fit into my combobox code I specified?

all help will do
0
 
rutgermonsAuthor Commented:
thanks for the solution, this wasnt a direct code fix in the macro but I used this sample and
opted the CF format instead and it works smoothly
0
 
yuppyduCommented:
rutgermons, I've added a comment right after the code posting saying that the Ddim was wrong and it shoud've been: Dim ItemCode as Double
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.