?
Solved

highlight entire selected range value row

Posted on 2013-11-24
9
Medium Priority
?
607 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 4

Expert Comment

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

Accepted Solution

by:
samrad1 earned 1500 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

762 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