Highlight a Row Depending on Active Cell Using Button?

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

Is there a way to highlight a row within a range when a cell is
active? The highlight needs to maintain the shading even though it is
no longer active. I've seen code on this site using Worksheet Change
Event but I was wondering if there was a way you could do this by a
Command Button so the user can highlight particular rows by clicking
on a button. For example, the user is on cell A5, clicks on the button
and it highlights Row A5:AV5.
 
The code is the same as what you saw in the worksheet_change examples
just that it goes in a normal subroutine. Your example would be:

Sub HiLiteIt()
Range("A" & ActiveCell.Row & ":AV"
ActiveCell.Row).Interior.ColorIndex = 33

End Sub

Change 33 to whatever color you want. Then create a button and assig
the macro to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top