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: 5,600
Default Conditional Formating

In your routine, rCell always refers to a cell in Col-AI (35) and
rCell.Offset(0, -34)
will always refer to a cell in col-A on the same row irrespective as to
whether any columns are hidden.

Run the following with some/all/no columns hidden

Sub test()
Dim rng As Range
Dim rCell As Range

Set rng = Range("AI4:AI5")

For Each rCell In rng
Debug.Print rCell.Offset(0, -34).Address(0, 0)
Next
End Sub

Press Ctrl-g to view the debugged addresses in the Immediate window.

Regards,
Peter T


There might be something
"Paul Brown" wrote in message
...
Hi all,

I've put the attached code together from the web. Am trying to amend the
font colour in column A based on the value in column AI for rows 4 to 500.
The problem is that depending on the view some columns are hidden and so

the
offset reference is a variable amount (I think it only counts visible
columns?) Can I name column A as the cell to be changed rather than offset
from column AI? (if so how!) The row will be variable based on the loop. I
can't use conditional formatting as am over the 3 allowed in Excel 2003.

The
following code works fine when all columns are visible but not when some

are
hidden. Many thanks.

Sub OrangeText()

Dim rng As Range

Dim rCell As Range

Set rng = Range("AI4:AI500")

For Each rCell In rng

If Val(rCell.Value) < 0 Then rCell.Offset(0, -34).Font.ColorIndex = 46

If Val(rCell.Value) = 0 Then rCell.Offset(0, -34).Font.ColorIndex = 1

Next

End Sub




 
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 formating david Excel Discussion (Misc queries) 1 July 25th 07 10:43 PM
Install dates formating using conditional formating? Jerry Eggleston Excel Discussion (Misc queries) 2 November 9th 05 05:49 PM
Conditional Formating George Excel Worksheet Functions 1 July 26th 05 09:33 PM
Conditional Formating Jon Ottman Excel Worksheet Functions 2 July 22nd 05 12:24 PM
Conditional formating Esrei Excel Discussion (Misc queries) 4 March 2nd 05 12:34 PM


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