M
Maury Markowitz
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
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