Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Wierd conditional formatting result (oops pressed send to soon!)

The Sub below is intended to extend the "Range1" to cover any new items in
column A and to enter conditional formatting to highlight any duplicates.

It works fine UNLESS the instruction "thisrange.Select" is removed. When
this is removed cell A1 ends up with the conditional format formula
"=(COUNTIF(Range1,A65527)1)"

I'm sure that the problem lies somewhere in the expression
Formula1:="=(COUNTIF(Range1,A1)1)"
but I am at a loss as to what I should put in its place.

Can anyone assist?

Public Sub rangered()
Set orig = Selection
Set thisrange = Range("a1",
Worksheets("Sheet1").Range("A1").End(xlDown))

thisrange.Select

thisrange.FormatConditions.Delete
thisrange.FormatConditions.Add Type:=xlExpression,
Formula1:="=(COUNTIF(Range1,A1)1)"
thisrange.FormatConditions(1).Interior.ColorIndex = 3
ActiveWorkbook.Names.Add Name:="Range1", RefersTo:=thisrange
orig.Select
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Wierd conditional formatting result (oops pressed send to soon!)

relative references in a conditional format are relative to the activecell.
So you need to select Range("A1") before applying the conditional format.

--
Regards,
Tom Ogilvy

"Paul Lautman" wrote in message
...
The Sub below is intended to extend the "Range1" to cover any new items in
column A and to enter conditional formatting to highlight any duplicates.

It works fine UNLESS the instruction "thisrange.Select" is removed. When
this is removed cell A1 ends up with the conditional format formula
"=(COUNTIF(Range1,A65527)1)"

I'm sure that the problem lies somewhere in the expression
Formula1:="=(COUNTIF(Range1,A1)1)"
but I am at a loss as to what I should put in its place.

Can anyone assist?

Public Sub rangered()
Set orig = Selection
Set thisrange = Range("a1",
Worksheets("Sheet1").Range("A1").End(xlDown))

thisrange.Select

thisrange.FormatConditions.Delete
thisrange.FormatConditions.Add Type:=xlExpression,
Formula1:="=(COUNTIF(Range1,A1)1)"
thisrange.FormatConditions(1).Interior.ColorIndex = 3
ActiveWorkbook.Names.Add Name:="Range1", RefersTo:=thisrange
orig.Select
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Wierd conditional formatting result (oops pressed send to soon!)

Thanks for that, I knew it had to be something like that. Based on you reply
I coded:

thisrange.FormatConditions.Add Type:=xlExpression,
Formula1:="=(COUNTIF(Range1," & Selection.Address(RowAbsolute:=False,
ColumnAbsolute:=False) & ")1)"

to cure it and save the .Select

"Tom Ogilvy" wrote in message
...
relative references in a conditional format are relative to the

activecell.
So you need to select Range("A1") before applying the conditional format.

--
Regards,
Tom Ogilvy

"Paul Lautman" wrote in message
...
The Sub below is intended to extend the "Range1" to cover any new items

in
column A and to enter conditional formatting to highlight any

duplicates.

It works fine UNLESS the instruction "thisrange.Select" is removed. When
this is removed cell A1 ends up with the conditional format formula
"=(COUNTIF(Range1,A65527)1)"

I'm sure that the problem lies somewhere in the expression
Formula1:="=(COUNTIF(Range1,A1)1)"
but I am at a loss as to what I should put in its place.

Can anyone assist?

Public Sub rangered()
Set orig = Selection
Set thisrange = Range("a1",
Worksheets("Sheet1").Range("A1").End(xlDown))

thisrange.Select

thisrange.FormatConditions.Delete
thisrange.FormatConditions.Add Type:=xlExpression,
Formula1:="=(COUNTIF(Range1,A1)1)"
thisrange.FormatConditions(1).Interior.ColorIndex = 3
ActiveWorkbook.Names.Add Name:="Range1", RefersTo:=thisrange
orig.Select
End Sub







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 Formatting Against a Formula - not it's result Mike The Newb Excel Discussion (Misc queries) 3 August 10th 06 10:33 PM
sound clip as a result of conditional formatting... ? sparky Excel Discussion (Misc queries) 6 December 18th 05 10:09 PM
How to preserve conditional formatting on a web query table result Simon L Excel Discussion (Misc queries) 9 February 26th 05 01:19 AM
Conditional Formatting using result of Cell Formulas Dave Peterson Excel Discussion (Misc queries) 0 January 26th 05 02:17 AM
Wierd conditional formatting result. Paul Lautman Excel Programming 1 June 21st 04 05:36 PM


All times are GMT +1. The time now is 07:07 PM.

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"