Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Value to be given to all cells with black background color

Hello,

I have a certain range of cells in which some of the cells are
formatted to have a black background color.
None of the cells contain any data.

I want to select the whole range of cells and then run a macro which
puts a "1" into each black cell. The white cells must stay empty.

How can I do this?

Regards,
Norbert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Value to be given to all cells with black background color

for each c in selection.cells
if c.interior.colorindex=1 then c.value=1
next c

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Value to be given to all cells with black background color


Dim cell As Range
For Each cell In ActiveSheet.UsedRange
If cell.Interior.Color = 0 Then
cell.Value = 1
cell.Font.Color = RGB(&HFF, &HFF, &HFF)
End If
Next cell


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Norbert Jaeger" wrote in message
...
Hello,

I have a certain range of cells in which some of the cells are
formatted to have a black background color.
None of the cells contain any data.

I want to select the whole range of cells and then run a macro which
puts a "1" into each black cell. The white cells must stay empty.

How can I do this?

Regards,
Norbert



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Value to be given to all cells with black background color

Dim ThisCell as Range
For Each ThisCell in Selection.Cells
If ThisCell.Interior.Color = vbBlack Then ThisCell.Value = 1
Next ThisCell

"Norbert Jaeger" wrote:

Hello,

I have a certain range of cells in which some of the cells are
formatted to have a black background color.
None of the cells contain any data.

I want to select the whole range of cells and then run a macro which
puts a "1" into each black cell. The white cells must stay empty.

How can I do this?

Regards,
Norbert


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Value to be given to all cells with black background color

Thanks to all of you.

All the code works.

Regards,
Norbert





On Tue, 17 May 2005 10:19:52 -0700, "K Dales"
wrote:

Dim ThisCell as Range
For Each ThisCell in Selection.Cells
If ThisCell.Interior.Color = vbBlack Then ThisCell.Value = 1
Next ThisCell

"Norbert Jaeger" wrote:

Hello,

I have a certain range of cells in which some of the cells are
formatted to have a black background color.
None of the cells contain any data.

I want to select the whole range of cells and then run a macro which
puts a "1" into each black cell. The white cells must stay empty.

How can I do this?

Regards,
Norbert



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
Black out Background of Userform Jeff Excel Discussion (Misc queries) 2 June 23rd 08 10:26 PM
How to add cells with a particular background color? BruceN1 Excel Discussion (Misc queries) 4 February 29th 08 10:05 PM
Excel color-formatted cells printing in black Chery Excel Worksheet Functions 2 January 16th 08 10:48 PM
The view colors in Excel 2003 cells change from color to black hawaiidoh Excel Discussion (Misc queries) 2 December 19th 07 06:59 PM
Applying background color to cells Erik[_6_] Excel Programming 2 February 26th 04 01:16 PM


All times are GMT +1. The time now is 04:22 AM.

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"