Programming, technology, and CRM – from a Belgian programmer exiled to Missouri
  • rss
  • Home
  • Contact Me
  • Welcome

Excel Conditional Formatting "moves" with selection, when set from VBScript

Nicolas Galler | September 15, 2007

This is an odd one… If you set a conditional formatting on an entire column (or a range) in Excel, and you use a relative reference (one that is not anchored with a dollar sign), and the currently selected cell is not the first one in the range… all the references will be shifted.

For example:

xlsWsh.Range("H1:H20").FormatConditions.Add xlExpression, , "=$B1=0"

Note I anchored the column, but not the row.
If prior to running this code the cell H8 was selected, then H8 will have as formula in the format condition, “=$B1=0″, instead of the expected “=$B8=0″.
The solution I used for now is to do

xlsWsh.Range("H1").Select

prior to running the rest.

Oh and strangely enough it seemed to run without problem from the VBA within Excel.

Categories
Programming
Comments rss
Comments rss
Trackback
Trackback

« Open file with associated application from VBScript Excel CopyFromRecordset Resets Filter »

Leave a Reply

Click here to cancel reply.

Categories

  • Experiments (4)
  • Interesting (1)
  • MSCRM (1)
  • Programming (60)
  • Rant (3)
  • Saleslogix (34)
  • Tricks (8)
  • Uncategorized (24)

Post History

  • 2010
    • January (3)
    • March (1)
  • 2009
    • March (2)
    • April (1)
    • May (3)
    • June (3)
    • July (1)
    • September (3)
    • October (2)
    • December (5)
  • 2008
    • January (9)
    • February (4)
    • March (9)
    • April (1)
    • May (5)
    • June (8)
    • July (1)
    • August (2)
    • September (1)
    • November (1)
    • December (3)
  • 2007
    • January (3)
    • February (7)
    • March (1)
    • April (3)
    • May (6)
    • June (2)
    • July (1)
    • August (2)
    • September (5)
    • October (3)
    • November (5)
    • December (4)
  • 2006
    • January (2)
    • September (1)
    • November (3)
    • December (4)
  • 2005
    • April (1)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox