Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need to insert value based on Background Color - 8KB Attach

You need to check the interior.colorindex of the cells, but for the
"standard" colors:

for each cell in selection
Select Case cell.Interior.ColorIndex
Case 3 'Red
Cell.Value = "Severe"
Case 4 'Green
cell.Value = "Slight"
Case 6 'Yellow
Cell.Value = "Minor"
End Select
Next

--
Regards,
Tom Ogilvy

"RT" wrote in message
...
I have to get a spreadsheet setup so I can import into Access. Certain
parts of it are color coded, Green - slight, Yellow = Minor, Red=Severe.

I
need to insert in the cell it's value. See attached.

Sorry for the binary but it's small. It's just so much easier than trying
to explain.

Thanks

RRT





  #2   Report Post  
Posted to microsoft.public.excel.programming
RT RT is offline
external usenet poster
 
Posts: 2
Default Need to insert value based on Background Color - 8KB Attach


You need to check the interior.colorindex of the cells, but for the
"standard" colors:

for each cell in selection
Select Case cell.Interior.ColorIndex
Case 3 'Red
Cell.Value = "Severe"
Case 4 'Green
cell.Value = "Slight"
Case 6 'Yellow
Cell.Value = "Minor"
End Select
Next

--
Regards,
Tom Ogilvy

In trying to get this working on just one cell I've tried:

Sub Macro2()
Select Case cell.Interior.ColorIndex
Case 46 'Color from 6th row 6th over
cell.Value = "Severe"
Case 20 'Green
cell.Value = "Slight"
Case 26 'Yellow
cell.Value = "Minor"
End Select

End Sub

What am i leaving out?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need to insert value based on Background Color - 8KB Attach

Sub Macro2()
Dim cell as Range
for each cell in selection
Select Case cell.Interior.ColorIndex
Case 46 'Color from 6th row 6th over
cell.Value = "Severe"
Case 20 'Green
cell.Value = "Slight"
Case 26 'Yellow
cell.Value = "Minor"
End Select
Next Cell
End Sub

Just select one or more cells.
less robust (only works on one cell)

Sub Macro2()
Select Case Activecell.Interior.ColorIndex
Case 46 'Color from 6th row 6th over
cell.Value = "Severe"
Case 20 'Green
cell.Value = "Slight"
Case 26 'Yellow
cell.Value = "Minor"
End Select
End Sub

--
Regards,
Tom Ogilvy

"RT" wrote in message
...

You need to check the interior.colorindex of the cells, but for the
"standard" colors:

for each cell in selection
Select Case cell.Interior.ColorIndex
Case 3 'Red
Cell.Value = "Severe"
Case 4 'Green
cell.Value = "Slight"
Case 6 'Yellow
Cell.Value = "Minor"
End Select
Next

--
Regards,
Tom Ogilvy

In trying to get this working on just one cell I've tried:

Sub Macro2()
Select Case cell.Interior.ColorIndex
Case 46 'Color from 6th row 6th over
cell.Value = "Severe"
Case 20 'Green
cell.Value = "Slight"
Case 26 'Yellow
cell.Value = "Minor"
End Select

End Sub

What am i leaving out?




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
Conditional Sum Based on Cell Background Color Thomas M. Excel Worksheet Functions 7 January 21st 13 11:14 PM
change background color based on range value DanL New Users to Excel 2 February 6th 09 09:35 PM
Change background color based on value in column A JT Innovations Excel Discussion (Misc queries) 4 January 23rd 09 07:14 PM
Changing background color based on different cell djarcadian Excel Discussion (Misc queries) 3 August 10th 06 10:44 PM
Setting cell background color based on value Erik[_5_] Excel Programming 3 February 25th 04 10:56 PM


All times are GMT +1. The time now is 03:59 PM.

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

About Us

"It's about Microsoft Excel"