Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Paste a conditional format without replacing existing formats??

Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if BPC
appears in column I.
But other columns also contain various seperate conditional formatting which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my macro.
EG can I first apply the yellow row formatting to the whole sheet then ADD
the seperate formats afterwards (can't copy and paste the formats from my
teplate sheet as this would overwrite)...

Help! :-)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Paste a conditional format without replacing existing formats??

Meltad,

Starting the Macro Recorder and defining two conditional formats for A1 this
is what I get. The first format turns it yellow if a cell in column I
contains "BPC". The second turns it red if it's equal to 0. Not quite what
you wanted, but it might help:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($I:$I,""BPC"")0"
Selection.FormatConditions(1).Interior.ColorIndex = 27
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="0"
Selection.FormatConditions(2).Interior.ColorIndex = 3

hth,

Doug


"Meltad" wrote in message
...
Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if
BPC
appears in column I.
But other columns also contain various seperate conditional formatting
which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my
macro.
EG can I first apply the yellow row formatting to the whole sheet then ADD
the seperate formats afterwards (can't copy and paste the formats from my
teplate sheet as this would overwrite)...

Help! :-)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Paste a conditional format without replacing existing formats?

Thanks Doug, I did a similar thing with the macro recorder and got the first
part sorted...

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($I1=""BPC"")"
Selection.FormatConditions(1).Interior.ColorIndex = 36
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select

My macro then inserts formulas into various columns in row 2 and copies
these down to nRows - I then applied the second layer of formatting by 'add'
in conditional format box but my red font doesn't work in cells already
highlighted yellow. It works for cells with no other format. Do you know of a
way to get the red font on the yellow background??? I'm sure I've seen this
working before...

Thanks




"Doug Glancy" wrote:

Meltad,

Starting the Macro Recorder and defining two conditional formats for A1 this
is what I get. The first format turns it yellow if a cell in column I
contains "BPC". The second turns it red if it's equal to 0. Not quite what
you wanted, but it might help:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($I:$I,""BPC"")0"
Selection.FormatConditions(1).Interior.ColorIndex = 27
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="0"
Selection.FormatConditions(2).Interior.ColorIndex = 3

hth,

Doug


"Meltad" wrote in message
...
Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if
BPC
appears in column I.
But other columns also contain various seperate conditional formatting
which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my
macro.
EG can I first apply the yellow row formatting to the whole sheet then ADD
the seperate formats afterwards (can't copy and paste the formats from my
teplate sheet as this would overwrite)...

Help! :-)




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Paste a conditional format without replacing existing formats?

Meltad,

Conditional formatting stops applying formatting after a condition is true,
i.e., if the first condition is true, it doesn't even evaluate the second
condition.

This means you need to apply the more restrictive, complex formatting first.
E.g., if you want cells that have a 0 in them AND have "BPC" in column I of
the same row, then you have to use an "AND" formula that captures both of
these. Your format would include both the yellow background and red font.

You could then have a second condition - less restrictive - that addresses
the condition where only column I has "BPC" and just turn the background
yellow:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($I1=""BPC"",$A1=0)"
Selection.FormatConditions(1).Font.ColorIndex = 3
Selection.FormatConditions(1).Interior.ColorIndex = 6
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=$I1=""BPC"""
Selection.FormatConditions(2).Interior.ColorIndex = 6

I hope that helps,

Doug

"Meltad" wrote in message
...
Thanks Doug, I did a similar thing with the macro recorder and got the
first
part sorted...

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($I1=""BPC"")"
Selection.FormatConditions(1).Interior.ColorIndex = 36
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select

My macro then inserts formulas into various columns in row 2 and copies
these down to nRows - I then applied the second layer of formatting by
'add'
in conditional format box but my red font doesn't work in cells already
highlighted yellow. It works for cells with no other format. Do you know
of a
way to get the red font on the yellow background??? I'm sure I've seen
this
working before...

Thanks




"Doug Glancy" wrote:

Meltad,

Starting the Macro Recorder and defining two conditional formats for A1
this
is what I get. The first format turns it yellow if a cell in column I
contains "BPC". The second turns it red if it's equal to 0. Not quite
what
you wanted, but it might help:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($I:$I,""BPC"")0"
Selection.FormatConditions(1).Interior.ColorIndex = 27
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,
_
Formula1:="0"
Selection.FormatConditions(2).Interior.ColorIndex = 3

hth,

Doug


"Meltad" wrote in message
...
Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if
BPC
appears in column I.
But other columns also contain various seperate conditional formatting
which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my
macro.
EG can I first apply the yellow row formatting to the whole sheet then
ADD
the seperate formats afterwards (can't copy and paste the formats from
my
teplate sheet as this would overwrite)...

Help! :-)






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Paste a conditional format without replacing existing formats?

That makes sense, thanks a lot Doug. I'll try his out on Monday and let you
know how it goes!

"Doug Glancy" wrote:

Meltad,

Conditional formatting stops applying formatting after a condition is true,
i.e., if the first condition is true, it doesn't even evaluate the second
condition.

This means you need to apply the more restrictive, complex formatting first.
E.g., if you want cells that have a 0 in them AND have "BPC" in column I of
the same row, then you have to use an "AND" formula that captures both of
these. Your format would include both the yellow background and red font.

You could then have a second condition - less restrictive - that addresses
the condition where only column I has "BPC" and just turn the background
yellow:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($I1=""BPC"",$A1=0)"
Selection.FormatConditions(1).Font.ColorIndex = 3
Selection.FormatConditions(1).Interior.ColorIndex = 6
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=$I1=""BPC"""
Selection.FormatConditions(2).Interior.ColorIndex = 6

I hope that helps,

Doug

"Meltad" wrote in message
...
Thanks Doug, I did a similar thing with the macro recorder and got the
first
part sorted...

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($I1=""BPC"")"
Selection.FormatConditions(1).Interior.ColorIndex = 36
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select

My macro then inserts formulas into various columns in row 2 and copies
these down to nRows - I then applied the second layer of formatting by
'add'
in conditional format box but my red font doesn't work in cells already
highlighted yellow. It works for cells with no other format. Do you know
of a
way to get the red font on the yellow background??? I'm sure I've seen
this
working before...

Thanks




"Doug Glancy" wrote:

Meltad,

Starting the Macro Recorder and defining two conditional formats for A1
this
is what I get. The first format turns it yellow if a cell in column I
contains "BPC". The second turns it red if it's equal to 0. Not quite
what
you wanted, but it might help:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($I:$I,""BPC"")0"
Selection.FormatConditions(1).Interior.ColorIndex = 27
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,
_
Formula1:="0"
Selection.FormatConditions(2).Interior.ColorIndex = 3

hth,

Doug


"Meltad" wrote in message
...
Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if
BPC
appears in column I.
But other columns also contain various seperate conditional formatting
which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my
macro.
EG can I first apply the yellow row formatting to the whole sheet then
ADD
the seperate formats afterwards (can't copy and paste the formats from
my
teplate sheet as this would overwrite)...

Help! :-)








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Paste a conditional format without replacing existing formats?

Thanks Doug, this works great

"Doug Glancy" wrote:

Meltad,

Conditional formatting stops applying formatting after a condition is true,
i.e., if the first condition is true, it doesn't even evaluate the second
condition.

This means you need to apply the more restrictive, complex formatting first.
E.g., if you want cells that have a 0 in them AND have "BPC" in column I of
the same row, then you have to use an "AND" formula that captures both of
these. Your format would include both the yellow background and red font.

You could then have a second condition - less restrictive - that addresses
the condition where only column I has "BPC" and just turn the background
yellow:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND($I1=""BPC"",$A1=0)"
Selection.FormatConditions(1).Font.ColorIndex = 3
Selection.FormatConditions(1).Interior.ColorIndex = 6
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=$I1=""BPC"""
Selection.FormatConditions(2).Interior.ColorIndex = 6

I hope that helps,

Doug

"Meltad" wrote in message
...
Thanks Doug, I did a similar thing with the macro recorder and got the
first
part sorted...

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=($I1=""BPC"")"
Selection.FormatConditions(1).Interior.ColorIndex = 36
Selection.Copy
Cells.Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select

My macro then inserts formulas into various columns in row 2 and copies
these down to nRows - I then applied the second layer of formatting by
'add'
in conditional format box but my red font doesn't work in cells already
highlighted yellow. It works for cells with no other format. Do you know
of a
way to get the red font on the yellow background??? I'm sure I've seen
this
working before...

Thanks




"Doug Glancy" wrote:

Meltad,

Starting the Macro Recorder and defining two conditional formats for A1
this
is what I get. The first format turns it yellow if a cell in column I
contains "BPC". The second turns it red if it's equal to 0. Not quite
what
you wanted, but it might help:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($I:$I,""BPC"")0"
Selection.FormatConditions(1).Interior.ColorIndex = 27
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,
_
Formula1:="0"
Selection.FormatConditions(2).Interior.ColorIndex = 3

hth,

Doug


"Meltad" wrote in message
...
Hi,

My worksheet has various conditional formatting.
The whole sheet is formatted to change the row fill colour to yellow if
BPC
appears in column I.
But other columns also contain various seperate conditional formatting
which
turn the font colour red.
Is there a way of applying both these formats to the same cell using my
macro.
EG can I first apply the yellow row formatting to the whole sheet then
ADD
the seperate formats afterwards (can't copy and paste the formats from
my
teplate sheet as this would overwrite)...

Help! :-)






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
Keeping Conditional Formats 'Constant' when copy & paste Porky79 Excel Discussion (Misc queries) 0 May 1st 09 02:11 PM
Conditional formats- paste special formats? jcarney Excel Discussion (Misc queries) 1 November 1st 07 06:37 PM
paste conditional formats as formats leo Excel Discussion (Misc queries) 2 July 5th 07 10:06 AM
Paste Special Formats Generated by Conditional Formatting ExcelMonkey Excel Discussion (Misc queries) 6 May 22nd 06 07:10 PM
Paste Conditional Formats Paul Excel Programming 3 September 20th 05 08:24 PM


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