Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default macro to put value in cell based on colour

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default macro to put value in cell based on colour

Sub Macro1()
'default yellow 65535
Set rngTemp = Range("A1:A10")
For Each cell In rngTemp
If cell.Interior.Color = 65535 Then cell.Value = "4"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default macro to put value in cell based on colour

I used this and it is still not working. Any suggestions?

Set rng = Range("R5:Y8")
For Each cell In rng
If cell.Interior.Color = 4 Then cell.Value = "100"
Next


"Jacob Skaria" wrote:

Sub Macro1()
'default yellow 65535
Set rngTemp = Range("A1:A10")
For Each cell In rngTemp
If cell.Interior.Color = 65535 Then cell.Value = "4"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default macro to put value in cell based on colour

I used this and it is not working. Any suggestions?

Set rng = Range("R5:Y8")
For Each cell In rng
If cell.Interior.Color = 4 Then cell.Value = "100"
Next


"Jacob Skaria" wrote:

Sub Macro1()
'default yellow 65535
Set rngTemp = Range("A1:A10")
For Each cell In rngTemp
If cell.Interior.Color = 65535 Then cell.Value = "4"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default macro to put value in cell based on colour

I think the color you are referring to is wrong
Try the yellow or red from the standard color pallete.
Yellow is 65535 or vbYellow.

If cell.Interior.Color = vbYellow Then cell.Value = "100"
OR
If cell.Interior.Color = 65535 Then cell.Value = "100"


If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I used this and it is still not working. Any suggestions?

Set rng = Range("R5:Y8")
For Each cell In rng
If cell.Interior.Color = 4 Then cell.Value = "100"
Next


"Jacob Skaria" wrote:

Sub Macro1()
'default yellow 65535
Set rngTemp = Range("A1:A10")
For Each cell In rngTemp
If cell.Interior.Color = 65535 Then cell.Value = "4"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default macro to put value in cell based on colour

Refer this for more help

http://www.mvps.org/dmcritchie/excel/colors.htm


If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number in a
cell if it has a certain colour, ie 4. Any suggestions?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default macro to put value in cell based on colour

The number 4 looks like a ColorIndex rather than a Color; try this...

If cell.Interior.ColorIndex = 4 Then cell.Value = "100"

While assigning "100" will work (Excel seems to do a behind the scenes
conversion and makes it a number), there is no need to put the quotes around
the 100, this will work as well...

If cell.Interior.ColorIndex = 4 Then cell.Value = 100

--
Rick (MVP - Excel)


"Kirsty" wrote in message
...
I used this and it is not working. Any suggestions?

Set rng = Range("R5:Y8")
For Each cell In rng
If cell.Interior.Color = 4 Then cell.Value = "100"
Next


"Jacob Skaria" wrote:

Sub Macro1()
'default yellow 65535
Set rngTemp = Range("A1:A10")
For Each cell In rngTemp
If cell.Interior.Color = 65535 Then cell.Value = "4"
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I want to write a macro (or formula) that allows me to place a number
in a
cell if it has a certain colour, ie 4. Any suggestions?


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 colour fill a row - based on cell value =100% Greg[_4_] Excel Worksheet Functions 2 April 29th 08 02:57 PM
how do i autofill a cell a certain colour based on it's value? dave Excel Worksheet Functions 2 January 27th 08 06:22 PM
Condition based on cell colour Richhall Excel Worksheet Functions 2 March 25th 07 04:23 PM
Colour Cell based on Content Steve Excel Worksheet Functions 3 March 10th 06 03:51 PM
How do I set a colour to 4 cells based on the value of a cell Andy64 Excel Discussion (Misc queries) 1 September 6th 05 06:46 PM


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