PDA

View Full Version : How to specify a formula for a cell?



chamster
10-17-2007, 10:58 PM
I went off and defined a formula that refers to a column. For some reason, the column i specify gets changed increasingly (e.g. "B"->"C", "C"->"E", "D"->"G", etc.).

I simply assumed that i do something to the references in th eprogram so i went off looking for that spot by the following string.
Debug.Print "to be verified: " & Sheets(3).Cells(2, 3).FormatConditions(1).Formula1 & vbnewline

To my astonishement, the output is
to be verified: =OM(MAX(E$2:E$25)=E3;SANT;FALSKT)
all the way through the program. After it has run finished, it's still the same. As soon as i try to edit the cells auto-format, though, it gets changed according to the scheme above.

Moreover, depending on which cell i mark, i get different results using the script above. It's probably a normal behavior and i'm too ignorant to understand why it happens. Any comments?

(As for the formula - it's supposed to colorify the cell with the maximum value in it's column. If you have a better suggestion for it, that's welcome as well.)

Bob Phillips
10-18-2007, 12:11 AM
Just use a formula of

=MAX($B$2:$B$25)=$B3

chamster
10-18-2007, 12:16 AM
Alright, that worked. Thanks!

Still, it's a little bit strange that it's needed, don't you think?

Bob Phillips
10-18-2007, 12:27 AM
No, Excel will adjust it otherwise, that is the way that Excel works.