LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default For Each x in Range

Yes. The line of code that I was missing was:

q.font.colorindex = 3

I know it sounds like a strange request. However, that's what the client
wants. To be able to loop through all the values in a given range, change
the font to red, then print out the same range over and over again.

Thanks to all for the insights and suggestions. I learned a lot.

C

--
Craig


"William" wrote:

Have you thought about using conditional formatting rather than looping
through the cells....

Sub test()
On Error Resume Next
With ActiveSheet
With .Range("Print_Area")
'if the print range has not been set
'use a range such as C1:R100
.FormatConditions.Delete
With .SpecialCells(xlCellTypeConstants, 1)
.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlNotEqual, Formula1:=0
.FormatConditions(1).Font.ColorIndex = 3
End With
With .SpecialCells(xlCellTypeFormulas, 1)
.FormatConditions.Add Type:=xlCellValue, _
Operator:=xlNotEqual, Formula1:=0
.FormatConditions(1).Font.ColorIndex = 3
End With
End With
.Printout
.Range("Print_Area").FormatConditions.Delete
End With
End Sub

Alternatively, you could play with the number formatting...

Sub test1()
With ActiveSheet
..Range("Print_Area").NumberFormat = "[Red][0]#,##0;[Red][<0]#,##0"
..PrintOut
..Range("Print_Area").NumberFormat = "#,##0_ ;[Red](#,##0)"
End With
End Sub

--


XL2003
Regards

William



"Craig" wrote in message
...
I'm using Excel 2000. I have a range that I'm iterating through (For Each
x
in Range...). If there is a number in the range, then I would like to
change
certain characteristics of that particular cell (font, color, etc.) and
then
have some other actions take place.

Is there a way to reference a particular cell this way (the only way I can
think of is to NOT use the For Each method, and instead, literally select
each cell in the range and use the Activecell.Offset method to advance to
the
next cell, etc. I'd prefer to not have to do it this way, though.

Any ideas? Thanks for any and all help.

--
Craig




 
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


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