Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Reading a color, and setting a value

I want to write an excel macro that looks at a cell, matches its color
against a known color value, and then assigns a value to another cell.

The difficulty is knowing how to assess the cell, and knowing what the excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know how to
come up with the color index (e.g. I do not know what number red is, what
number cyan is, etc.).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Reading a color, and setting a value

Look for
Color Palette -- the 56 Excel Colors
http://www.mvps.org/dmcritchie/excel...s.htm#dpalette

--
HTH

Bob Phillips

"Mark from Princeton" wrote in
message ...
I want to write an excel macro that looks at a cell, matches its color
against a known color value, and then assigns a value to another cell.

The difficulty is knowing how to assess the cell, and knowing what the

excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know how to
come up with the color index (e.g. I do not know what number red is, what
number cyan is, etc.).



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Reading a color, and setting a value

That is a great resource thank you. It answers part of my question.

The other part is how to address the cell properly. the pseudocode I wrote
is what I want to do, but I don't know the best way to implement it.

"Bob Phillips" wrote:

Look for
Color Palette -- the 56 Excel Colors
http://www.mvps.org/dmcritchie/excel...s.htm#dpalette

--
HTH

Bob Phillips

"Mark from Princeton" wrote in
message ...
I want to write an excel macro that looks at a cell, matches its color
against a known color value, and then assigns a value to another cell.

The difficulty is knowing how to assess the cell, and knowing what the

excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know how to
come up with the color index (e.g. I do not know what number red is, what
number cyan is, etc.).




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Reading a color, and setting a value

It is very close to real code. It would just be something like

If Range("B1").interior.colorindex = 36 then
Range("C1").value = 1
end if


--
HTH

Bob Phillips

"Mark from Princeton" wrote in
message ...
That is a great resource thank you. It answers part of my question.

The other part is how to address the cell properly. the pseudocode I

wrote
is what I want to do, but I don't know the best way to implement it.

"Bob Phillips" wrote:

Look for
Color Palette -- the 56 Excel Colors
http://www.mvps.org/dmcritchie/excel...s.htm#dpalette

--
HTH

Bob Phillips

"Mark from Princeton"

wrote in
message ...
I want to write an excel macro that looks at a cell, matches its color
against a known color value, and then assigns a value to another cell.

The difficulty is knowing how to assess the cell, and knowing what the

excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know how

to
come up with the color index (e.g. I do not know what number red is,

what
number cyan is, etc.).






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Reading a color, and setting a value

Thank you very much, that is helpful. I am getting much closer. I am
missing some sort of fundamental concept about ranges. Here is the VB code I
wrote which is syntactically correct but gives me a range of global object
failed

or i = 3 To 6168
If Range("e(i)").Interior.ColorIndex = 35 Then
Range("f(i)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 15 Then
Range("f(i)").Value = 2
ElseIf Range("e(i)").Interior.ColorIndex = 38 Then
Range("f(i)").Value = 3
ElseIf Range("e(i)").Interior.ColorIndex = 4 Then
Range("f(i)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 37 Then
Range("f(i)").Value = 4
End If
Next i
'does the other varialbes
For ii = 3 To 6168
If Range("e(ii)").Interior.ColorIndex = 34 Then 'changover
Range("g(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 6 Then 'PM
Range("h(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 50 Then 'cold startup
Range("i(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 44 Then 'noparts/tooling
Range("j(ii)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 41 Then ' raw materials
Range("k(ii)").Value = 4

ElseIf Range("h(i)").Interior.ColorIndex = 12 Then 'meeting
Range("l(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 42 Then 'met committment
Range("m(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 43 Then 'eng testing
Range("n(ii)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 40 Then 'power out
Range("o(ii)").Value = 4

ElseIf Range("e(i)").Interior.ColorIndex = 7 Then 'holiday/lunch
Range("p(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 8 Then 'line record
Range("q(ii)").Value = 1

End If
Next ii


"Bob Phillips" wrote:

It is very close to real code. It would just be something like

If Range("B1").interior.colorindex = 36 then
Range("C1").value = 1
end if


--
HTH

Bob Phillips

"Mark from Princeton" wrote in
message ...
That is a great resource thank you. It answers part of my question.

The other part is how to address the cell properly. the pseudocode I

wrote
is what I want to do, but I don't know the best way to implement it.

"Bob Phillips" wrote:

Look for
Color Palette -- the 56 Excel Colors
http://www.mvps.org/dmcritchie/excel...s.htm#dpalette

--
HTH

Bob Phillips

"Mark from Princeton"

wrote in
message ...
I want to write an excel macro that looks at a cell, matches its color
against a known color value, and then assigns a value to another cell.

The difficulty is knowing how to assess the cell, and knowing what the
excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know how

to
come up with the color index (e.g. I do not know what number red is,

what
number cyan is, etc.).








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Reading a color, and setting a value

Just a pointer

Not

If Range("e(i)").Interior.ColorIndex = 35 Then

but

If Range("e" & i).Interior.ColorIndex = 35 Then

as the address is a string.

--
HTH

Bob Phillips

"Mark from Princeton" wrote in
message ...
Thank you very much, that is helpful. I am getting much closer. I am
missing some sort of fundamental concept about ranges. Here is the VB

code I
wrote which is syntactically correct but gives me a range of global object
failed

or i = 3 To 6168
If Range("e(i)").Interior.ColorIndex = 35 Then
Range("f(i)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 15 Then
Range("f(i)").Value = 2
ElseIf Range("e(i)").Interior.ColorIndex = 38 Then
Range("f(i)").Value = 3
ElseIf Range("e(i)").Interior.ColorIndex = 4 Then
Range("f(i)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 37 Then
Range("f(i)").Value = 4
End If
Next i
'does the other varialbes
For ii = 3 To 6168
If Range("e(ii)").Interior.ColorIndex = 34 Then 'changover
Range("g(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 6 Then 'PM
Range("h(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 50 Then 'cold startup
Range("i(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 44 Then 'noparts/tooling
Range("j(ii)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 41 Then ' raw materials
Range("k(ii)").Value = 4

ElseIf Range("h(i)").Interior.ColorIndex = 12 Then 'meeting
Range("l(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 42 Then 'met committment
Range("m(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 43 Then 'eng testing
Range("n(ii)").Value = 4
ElseIf Range("e(i)").Interior.ColorIndex = 40 Then 'power out
Range("o(ii)").Value = 4

ElseIf Range("e(i)").Interior.ColorIndex = 7 Then 'holiday/lunch
Range("p(ii)").Value = 1
ElseIf Range("e(i)").Interior.ColorIndex = 8 Then 'line record
Range("q(ii)").Value = 1

End If
Next ii


"Bob Phillips" wrote:

It is very close to real code. It would just be something like

If Range("B1").interior.colorindex = 36 then
Range("C1").value = 1
end if


--
HTH

Bob Phillips

"Mark from Princeton"

wrote in
message ...
That is a great resource thank you. It answers part of my question.

The other part is how to address the cell properly. the pseudocode I

wrote
is what I want to do, but I don't know the best way to implement it.

"Bob Phillips" wrote:

Look for
Color Palette -- the 56 Excel Colors
http://www.mvps.org/dmcritchie/excel...s.htm#dpalette

--
HTH

Bob Phillips

"Mark from Princeton"

wrote in
message ...
I want to write an excel macro that looks at a cell, matches its

color
against a known color value, and then assigns a value to another

cell.

The difficulty is knowing how to assess the cell, and knowing what

the
excel
standard color numbers are.

for example I should be able to use something like:

If aCell.interior.colorindex = 36 then
anotherCell.value = 1
end if

I am just not addressing the cell properly and I also do not know

how
to
come up with the color index (e.g. I do not know what number red

is,
what
number cyan is, etc.).








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
Setting Wall Color in 3-D charts Marian Charts and Charting in Excel 1 August 26th 09 01:46 AM
Reading RGB background color from cell Don Wiss Excel Programming 3 August 6th 05 03:56 AM
Automatic color setting in Excel Bogeyfre Excel Discussion (Misc queries) 4 June 12th 05 06:43 PM
Setting Color of PIE sections Vishesh Vyas Charts and Charting in Excel 2 May 5th 05 10:15 AM
setting cell color Wazooli Excel Worksheet Functions 9 January 19th 05 02:21 AM


All times are GMT +1. The time now is 09:59 AM.

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"