Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default conditional format problem

can anyone explain to me why this happens in this code?

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D8$D$" & tblRows + 1
End With

tblrows = 31 so the expression equates to =$D8$D$32

but the equation in row 8 is =$D9$D$32. each row is off by one.

the operation before this is a copy to f7:f31 and it's still selected, so i
am guessing this is throwing it off

if i do a selection of a single cell, it appears to enter the formula ok.
any way around this without selecting a cell?
--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default conditional format problem

Hi Gary,

It is because you have left the row number relative, so Excel (smartly)
updates it for you. If you always want 8, use

"=$D$8$D$" & tblRows + 1



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
can anyone explain to me why this happens in this code?

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D8$D$" & tblRows + 1
End With

tblrows = 31 so the expression equates to =$D8$D$32

but the equation in row 8 is =$D9$D$32. each row is off by one.

the operation before this is a copy to f7:f31 and it's still selected, so

i
am guessing this is throwing it off

if i do a selection of a single cell, it appears to enter the formula ok.
any way around this without selecting a cell?
--


Gary





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default conditional format problem

bob:

therein lies the problem. i don't always want to use D8. i always want to
use D32, which the variable equates to, but i want to use D8 in row 8, D9 in
row 9 and so on.

--


Gary


"Bob Phillips" wrote in message
...
Hi Gary,

It is because you have left the row number relative, so Excel (smartly)
updates it for you. If you always want 8, use

"=$D$8$D$" & tblRows + 1



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
can anyone explain to me why this happens in this code?

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D8$D$" & tblRows + 1
End With

tblrows = 31 so the expression equates to =$D8$D$32

but the equation in row 8 is =$D9$D$32. each row is off by one.

the operation before this is a copy to f7:f31 and it's still selected, so

i
am guessing this is throwing it off

if i do a selection of a single cell, it appears to enter the formula ok.
any way around this without selecting a cell?
--


Gary







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default conditional format problem

Gary,

I am not too sure what problem you are experiencing, but it may be that it
doesn't start at 8 because of the activecell. Try this alternative

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D" & ActiveCell.Row & "$D$" & tblRows
End With



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
bob:

therein lies the problem. i don't always want to use D8. i always want to
use D32, which the variable equates to, but i want to use D8 in row 8, D9

in
row 9 and so on.

--


Gary


"Bob Phillips" wrote in message
...
Hi Gary,

It is because you have left the row number relative, so Excel (smartly)
updates it for you. If you always want 8, use

"=$D$8$D$" & tblRows + 1



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
can anyone explain to me why this happens in this code?

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D8$D$" & tblRows + 1
End With

tblrows = 31 so the expression equates to =$D8$D$32

but the equation in row 8 is =$D9$D$32. each row is off by one.

the operation before this is a copy to f7:f31 and it's still selected,

so
i
am guessing this is throwing it off

if i do a selection of a single cell, it appears to enter the formula

ok.
any way around this without selecting a cell?
--


Gary









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default conditional format problem

will do, got around it for now by just selecting a cell in row 8.

--


Gary


"Bob Phillips" wrote in message
...
Gary,

I am not too sure what problem you are experiencing, but it may be that it
doesn't start at 8 because of the activecell. Try this alternative

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D" & ActiveCell.Row & "$D$" & tblRows
End With



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
bob:

therein lies the problem. i don't always want to use D8. i always want to
use D32, which the variable equates to, but i want to use D8 in row 8, D9

in
row 9 and so on.

--


Gary


"Bob Phillips" wrote in message
...
Hi Gary,

It is because you have left the row number relative, so Excel (smartly)
updates it for you. If you always want 8, use

"=$D$8$D$" & tblRows + 1



--

HTH

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


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
can anyone explain to me why this happens in this code?

Set rng = Range("B8:f" & tblRows)
With rng
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=$D8$D$" & tblRows + 1
End With

tblrows = 31 so the expression equates to =$D8$D$32

but the equation in row 8 is =$D9$D$32. each row is off by one.

the operation before this is a copy to f7:f31 and it's still selected,

so
i
am guessing this is throwing it off

if i do a selection of a single cell, it appears to enter the formula

ok.
any way around this without selecting a cell?
--


Gary













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
Conditional Format Problem WLMPilot Excel Discussion (Misc queries) 4 November 17th 06 04:07 PM
Conditional Format Problem E.Q. Excel Discussion (Misc queries) 1 September 9th 06 05:41 AM
conditional format problem John New Users to Excel 4 July 16th 06 05:23 PM
Conditional format problem PJ Excel Discussion (Misc queries) 2 March 11th 05 02:05 PM
help please with conditional format problem Graham Warren Excel Worksheet Functions 1 November 7th 04 05:57 PM


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