Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Conditional Formatting Not Working In Macro

Hi Guys,

I have the following code at the end of my macro:

Columns("F:F").FormatConditions.Delete
Columns("F:F").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(F1)"
Columns("F:F").FormatConditions(1).Font.ColorIndex = 2

Columns("G:G").FormatConditions.Delete
Columns("G:G").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(G1)"
Columns("G:G").FormatConditions(1).Font.ColorIndex = 2

Columns("H:H").FormatConditions.Delete
Columns("H:H").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(H1)"
Columns("H:H").FormatConditions(1).Font.ColorIndex = 2

Columns("I:I").FormatConditions.Delete
Columns("I:I").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(I1)"
Columns("I:I").FormatConditions(1).Font.ColorIndex = 2

However nothing happens when this runs. Everything before it does run, so
I'm unsure as to why this is not working.

Thanks!
Dave

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default Conditional Formatting Not Working In Macro

You set the conditions, but not the format. Try adding something like this
to each

Selection.FormatConditions(1).Font.ColorIndex = 3 '< Is red
Selection.FormatConditions(1).Interior.ColorIndex = 36 '< is light
yellow

--
HTH,
Barb Reinhardt



"Dave" wrote:

Hi Guys,

I have the following code at the end of my macro:

Columns("F:F").FormatConditions.Delete
Columns("F:F").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(F1)"
Columns("F:F").FormatConditions(1).Font.ColorIndex = 2

Columns("G:G").FormatConditions.Delete
Columns("G:G").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(G1)"
Columns("G:G").FormatConditions(1).Font.ColorIndex = 2

Columns("H:H").FormatConditions.Delete
Columns("H:H").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(H1)"
Columns("H:H").FormatConditions(1).Font.ColorIndex = 2

Columns("I:I").FormatConditions.Delete
Columns("I:I").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(I1)"
Columns("I:I").FormatConditions(1).Font.ColorIndex = 2

However nothing happens when this runs. Everything before it does run, so
I'm unsure as to why this is not working.

Thanks!
Dave

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Conditional Formatting Not Working In Macro

I have set the conditions already.

See: Columns("F:F").FormatConditions(1).Font.ColorIndex = 2

Dave

"Barb Reinhardt" wrote:

You set the conditions, but not the format. Try adding something like this
to each

Selection.FormatConditions(1).Font.ColorIndex = 3 '< Is red
Selection.FormatConditions(1).Interior.ColorIndex = 36 '< is light
yellow

--
HTH,
Barb Reinhardt



"Dave" wrote:

Hi Guys,

I have the following code at the end of my macro:

Columns("F:F").FormatConditions.Delete
Columns("F:F").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(F1)"
Columns("F:F").FormatConditions(1).Font.ColorIndex = 2

Columns("G:G").FormatConditions.Delete
Columns("G:G").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(G1)"
Columns("G:G").FormatConditions(1).Font.ColorIndex = 2

Columns("H:H").FormatConditions.Delete
Columns("H:H").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(H1)"
Columns("H:H").FormatConditions(1).Font.ColorIndex = 2

Columns("I:I").FormatConditions.Delete
Columns("I:I").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(I1)"
Columns("I:I").FormatConditions(1).Font.ColorIndex = 2

However nothing happens when this runs. Everything before it does run, so
I'm unsure as to why this is not working.

Thanks!
Dave

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Conditional Formatting Not Working In Macro

Applying conditional formatting from VBA can be weird.

See John Walkenbach's Oddities page:
http://j-walk.com/ss/excel/odd/odd07.htm

One way around the problem is to select the range first.

Columns("F:F").select
Columns("F:F").FormatConditions.Delete
....

Dave wrote:

Hi Guys,

I have the following code at the end of my macro:

Columns("F:F").FormatConditions.Delete
Columns("F:F").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(F1)"
Columns("F:F").FormatConditions(1).Font.ColorIndex = 2

Columns("G:G").FormatConditions.Delete
Columns("G:G").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(G1)"
Columns("G:G").FormatConditions(1).Font.ColorIndex = 2

Columns("H:H").FormatConditions.Delete
Columns("H:H").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(H1)"
Columns("H:H").FormatConditions(1).Font.ColorIndex = 2

Columns("I:I").FormatConditions.Delete
Columns("I:I").FormatConditions.Add Type:=xlExpression,
Formula1:="=ISERROR(I1)"
Columns("I:I").FormatConditions(1).Font.ColorIndex = 2

However nothing happens when this runs. Everything before it does run, so
I'm unsure as to why this is not working.

Thanks!
Dave


--

Dave Peterson
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
IF function not working in conditional formatting DruD Excel Worksheet Functions 7 June 25th 07 05:18 PM
Conditional Formatting isnt working right changetires Excel Discussion (Misc queries) 6 June 28th 06 08:47 PM
Conditional Formatting is not working... tmerton Excel Worksheet Functions 1 March 17th 06 10:42 PM
conditional formatting not working in every cell mhutch71 Excel Discussion (Misc queries) 3 January 4th 06 08:19 PM
Conditional Formatting Not Working Consistently Christina Excel Discussion (Misc queries) 6 July 22nd 05 11:55 PM


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