Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Range of Cells


Hi folks:

I've been trying to work on some code that would color, let's say 30
consecutive cells on the same row if the firt one is not empty.
Something like...

range("A5").select
if activecell.select < "" then "color the 30 cells on that row to the
right of A5"
activecell.offset (0,1).select
and keep testing until cell is "blank"

Any help would be appreciated.





--
halem2
------------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930
View this thread: http://www.excelforum.com/showthread...hreadid=502237

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Color Range of Cells


"halem2" wrote in message
...

Hi folks:

I've been trying to work on some code that would color, let's say 30
consecutive cells on the same row if the firt one is not empty.
Something like...

range("A5").select
if activecell.select < "" then "color the 30 cells on that row to the
right of A5"
activecell.offset (0,1).select
and keep testing until cell is "blank"

Any help would be appreciated.


You don't need code for that.
It can be done with a simple conditional format.
Select the cells you want to give a color depending on cell A5.
Enter conditional format:
"Formula is"
=IF( $A5="", 1, 0 )
and hit the format button to choose a pattern.

Dirk Vdm


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Color Range of Cells

Simpler formula - =$A5=""

--

HTH

RP

"Dirk Van de moortel" wrote
in message ...

"halem2" wrote in

message
...

Hi folks:

I've been trying to work on some code that would color, let's say 30
consecutive cells on the same row if the firt one is not empty.
Something like...

range("A5").select
if activecell.select < "" then "color the 30 cells on that row to the
right of A5"
activecell.offset (0,1).select
and keep testing until cell is "blank"

Any help would be appreciated.


You don't need code for that.
It can be done with a simple conditional format.
Select the cells you want to give a color depending on cell A5.
Enter conditional format:
"Formula is"
=IF( $A5="", 1, 0 )
and hit the format button to choose a pattern.

Dirk Vdm




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Color Range of Cells


"Bob Phillips" wrote in message ...
Simpler formula - =$A5=""


Yep, but then I would write it as
= ( $A5 = "" )

Dirk Vdm


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Range of Cells


I think I did not explained what I need correctly. I need to color
alternating rows and once I move down to a cell that is empty, stop the
code. I need to use code because the spreadsheets we work with have
over 4000 rows and I really don't want to apply conditional formatting
to 2000 rows.

Besides, I need to include it as part of a macro I give to users. Also
the cells can have either letters or numbers.

thanks


--
halem2
------------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930
View this thread: http://www.excelforum.com/showthread...hreadid=502237



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color Range of Cells


I want to thank every one for their help. This is how I solved my
problem

Sub ColoringAltRows()
'
Dim r1 As Integer ' counter for cells all the way to 60 on same row
Dim r2 As Integer 'last non blank cell in column A
'
Range("A5").Select
'
Do Until ActiveCell = ""
For r1 = 1 To 60
With Selection.Interior
..ColorIndex = 35
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
ActiveCell.Offset(0, 1).Select
End With
Next r1
ActiveCell.Offset(2, -60).Select
Loop
End Sub


--
halem2
------------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...fo&userid=9930
View this thread: http://www.excelforum.com/showthread...hreadid=502237

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
Change the color of a range of cells Srajes New Users to Excel 6 June 24th 09 08:02 PM
change the color of a range of cells Srajes Excel Discussion (Misc queries) 1 June 24th 09 03:47 PM
color a range of cells based on a criteria Dave F Excel Discussion (Misc queries) 2 October 13th 06 02:29 PM
Formula to count the cells in a range that have a fill color. Molly F Excel Discussion (Misc queries) 2 January 19th 05 06:15 PM
Changing color on a range of cells Pete Excel Programming 3 December 31st 03 10:03 PM


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