LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default How do I reference cells in CF formula within loop

I want to add a conditional format to every cell in the range A1:C3
where the formula in the conditional format references the cell 10
rows below the current cell, for instance for cell A1 the formula is:

=A1<A11

and the formula for B1 is:

=B1<B11

and so on.

I have the following loop to create the conditional formats but I
don't know how to create the formula to reference the cells correctly
as the loop executes.

For Each c In Range("A1:C3)
c.FormatConditions.Delete
c.FormatConditions.Add Type:=xlExpression, _
Formula1:="=A1<A11
c.FormatConditions(1).Interior.ColorIndex = 36
Next c

How do I use the right variable so the correct formulas are created?

TIA



John Keith

 
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
Need to reference two cells to construct formula DaisyGirl Excel Programming 1 June 14th 09 06:14 PM
Loop for formula on one sheet with reference from another sheet Valerie Excel Programming 1 August 28th 08 05:22 PM
Putting formula in cells from a loop Andreww Excel Programming 1 February 13th 07 11:55 AM
For Each ... Next loop - need to reference the loop variable [email protected] Excel Programming 4 July 13th 06 06:12 PM
My formula screws up other reference cells... Jambruins Excel Discussion (Misc queries) 2 February 28th 05 02:57 PM


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