Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Change Cell background color by selection

Excel 2003

I have a table of data, and I would like to have a section of it highlighted
with a different background color when the user selects the first cell in
the row (selecting this cell also drives a couple of other functions as well
using the Worksheet_SelectionChange function).

The table range is from A7:D14.
When A7 is selected, I'd like to have A7:D7 background change to yellow.
When a different cell is selected, I need A7:D14 to revert back to their
original
format (gray background) and have the new selection change to the yellow
background.

Any thoughts will be greatly appreciated!





  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Change Cell background color by selection

Put this in worksheet code:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim block As Range
Dim point As Range
Set block = Range(Cells(7, 1), Cells(14, 4))
Set point = Cells(7, 1)

Cells.Interior.ColorIndex = xlNone

If Not Intersect(Target, point) Is Nothing Then
block.Interior.ColorIndex = 6
Else
Target.Interior.ColorIndex = 6
End If
End Sub


If A7 is selected, the block will be yellow. If any other cell is selected,
then that cell is made yellow.
--
Gary's Student


"Bob Wall" wrote:

Excel 2003

I have a table of data, and I would like to have a section of it highlighted
with a different background color when the user selects the first cell in
the row (selecting this cell also drives a couple of other functions as well
using the Worksheet_SelectionChange function).

The table range is from A7:D14.
When A7 is selected, I'd like to have A7:D7 background change to yellow.
When a different cell is selected, I need A7:D14 to revert back to their
original
format (gray background) and have the new selection change to the yellow
background.

Any thoughts will be greatly appreciated!






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
What is the macro to change background based on numeric cell value Still learning Excel Worksheet Functions 2 June 21st 06 05:58 PM
change cell background color when another cell's value = 40 da haole boy Excel Discussion (Misc queries) 2 February 19th 06 01:42 AM
change cell shading whenever contents different from previous cell zooeyhallne Excel Discussion (Misc queries) 3 June 6th 05 09:59 PM
background color of my cell does not change Colorblinded Excel Discussion (Misc queries) 2 March 27th 05 04:55 PM


All times are GMT +1. The time now is 11:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"