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: 119
Default Programmatically adding a conditional format

I had this working before, but now I can't get the syntax correct...

I am looping over a series of cells in a column and adding a formula
to fetch the latest price from bloomberg. Not every row can be
fetched, perhaps 1/3rd of them on average. There is another column
that holds the last price that the user typed in.

Sometimes these return errors. Sadly they cannot be found using
ISERROR, and you have to LEFT the text instead, looking for the hash.

The user doesn't want to see the error if the fetch doesn't work. So I
have a second column with a formula in it, if the # is there it reads
the user price, if there is no # it reads the bloomberg price.

So far so good.

Now I want to color the border of the cell, to indicate to the user
whether or not the price fetch worked. If it did work, I want it to be
blue, and if it failed (and the original user price is being
displayed) I want it to be red. So here's what I did...

Set rng = Range(userPriceCol & i)
rng.Borders.LineStyle = xlContinuous
rng.Borders.ColorIndex = 5
rng.FormatConditions.Delete
rng.FormatConditions.Add
rng.FormatConditions(1).Formula1 = "=LEFT(" & bbgcol &
i & ",1)=""#"""
rng.FormatConditions(1).Borders.ColorIndex = vbRed

The code fails on "Add", telling me that it has the "wrong number of
arguments..." Then I tried

rng.FormatConditions.Add 'Type:=xlExpression

But this says "argument not optional".

Does anyone know the right syntax here?

Maury

 
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
How to programmatically access Number Format String in the Format xiao Excel Programming 3 April 16th 08 08:18 PM
Adding in another conditional format on the same cell Kelly Lim Excel Discussion (Misc queries) 4 May 23rd 05 09:38 AM
Adding to AutoComplete programmatically Jim McLeod Excel Programming 3 April 19th 04 05:29 PM
Adding comment programmatically Carl Rapson Excel Programming 3 February 26th 04 11:01 PM
Adding Checkboxes Programmatically Mark D'Agosta Excel Programming 1 October 8th 03 03:20 AM


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