Solved

highlight entire selected range value row

Posted on 2013-11-24
9
599 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:rutgermons
[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
  • 4
  • 4
9 Comments
 
LVL 4

Expert Comment

by:yuppydu
ID: 39672844
The combobox is in a form or on a sheet?
0
 

Author Comment

by:rutgermons
ID: 39672856
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
 
LVL 4

Expert Comment

by:yuppydu
ID: 39672924
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:yuppydu
ID: 39672927
Sorry the Dim is: Dim ItemCode as Double
0
 
LVL 2

Accepted Solution

by:
samrad1 earned 500 total points
ID: 39673132
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
 

Author Comment

by:rutgermons
ID: 39673290
samrad

can u send me the vba code pls?
0
 

Author Comment

by:rutgermons
ID: 39673387
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
 

Author Closing Comment

by:rutgermons
ID: 39673437
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
 
LVL 4

Expert Comment

by:yuppydu
ID: 39673790
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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Database 5 44
need assistance with a VBscript 3 36
Vlookup - 2 criteria 6 43
Excel Data Validation Help 9 43
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

756 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