Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Insert text based on another cell's colour or font in Excel 2003

eI have a table of data (b2:f600). Some of the rows are green, some yellow,
etc. I need a formula/macro that will put a number or text in column A based
on the row's colour (eg if b2 is green then put "1" or "green" in a2). The
coloured rows are not in consecutive order. I use Excel 2003. Anyone?
  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Insert text based on another cell's colour or font in Excel 2003

hi
see this site for xl color indexes...
http://www.mvps.org/dmcritchie/excel/colors.htm
Sub testit()
Dim r As Range
Dim rd As Range
Set r = Range("B1")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
r.Select
If r.Interior.ColorIndex = 4 Then 'green
r.Offset(0, -1).Value = 1 'or A
Else
If r.Interior.ColorIndex = 6 Then 'yellow
r.Offset(0, -1).Value = 2 'or b
End If
End If
Set r = rd
Loop
MsgBox ("Done!")
End Sub

regards
FSt1

"Philip Hinton" wrote:

eI have a table of data (b2:f600). Some of the rows are green, some yellow,
etc. I need a formula/macro that will put a number or text in column A based
on the row's colour (eg if b2 is green then put "1" or "green" in a2). The
coloured rows are not in consecutive order. I use Excel 2003. Anyone?

  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Insert text based on another cell's colour or font in Excel 20

hi
remove r.select; i just added that as part of the test. no need to select
anything.
sorry.
regards
FSt1



"FSt1" wrote:

hi
see this site for xl color indexes...
http://www.mvps.org/dmcritchie/excel/colors.htm
Sub testit()
Dim r As Range
Dim rd As Range
Set r = Range("B1")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
r.Select
If r.Interior.ColorIndex = 4 Then 'green
r.Offset(0, -1).Value = 1 'or A
Else
If r.Interior.ColorIndex = 6 Then 'yellow
r.Offset(0, -1).Value = 2 'or b
End If
End If
Set r = rd
Loop
MsgBox ("Done!")
End Sub

regards
FSt1

"Philip Hinton" wrote:

eI have a table of data (b2:f600). Some of the rows are green, some yellow,
etc. I need a formula/macro that will put a number or text in column A based
on the row's colour (eg if b2 is green then put "1" or "green" in a2). The
coloured rows are not in consecutive order. I use Excel 2003. Anyone?

  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Insert text based on another cell's colour or font in Excel 20

Thanks for the input FSt1. Your code works but only if the rows are coloured
"yellow" or "bright green" (as Excel sees them). I need something that will
give a result for ANY colour. However, I followed up on your dmcritchie link
and found http://www.cpearson.com/excel/SortByColor.htm, which does it for
me. Thanks for the pointers.
Philip

"FSt1" wrote:

hi
see this site for xl color indexes...
http://www.mvps.org/dmcritchie/excel/colors.htm
Sub testit()
Dim r As Range
Dim rd As Range
Set r = Range("B1")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
r.Select
If r.Interior.ColorIndex = 4 Then 'green
r.Offset(0, -1).Value = 1 'or A
Else
If r.Interior.ColorIndex = 6 Then 'yellow
r.Offset(0, -1).Value = 2 'or b
End If
End If
Set r = rd
Loop
MsgBox ("Done!")
End Sub

regards
FSt1

"Philip Hinton" wrote:

eI have a table of data (b2:f600). Some of the rows are green, some yellow,
etc. I need a formula/macro that will put a number or text in column A based
on the row's colour (eg if b2 is green then put "1" or "green" in a2). The
coloured rows are not in consecutive order. I use Excel 2003. Anyone?

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
Formatting a cell with colour based on whether another cell's valu Kierano Excel Worksheet Functions 1 October 11th 06 06:05 PM
Pulling out data based on font colour terryc Excel Discussion (Misc queries) 1 July 3rd 06 09:51 PM
VLOOKUP based on PART of another cell's text djDaemon Excel Discussion (Misc queries) 0 March 9th 06 01:08 PM
font colour won't change in Excel 2003 BAB Excel Discussion (Misc queries) 1 February 10th 06 02:56 PM
Change Font colour mid-worksheet: Excel 2003 John L Excel Discussion (Misc queries) 2 July 12th 05 12:58 PM


All times are GMT +1. The time now is 11:16 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"