+ Reply to Thread
Results 1 to 3 of 3

VB Macro, FOR loop with conditional formatting

  1. #1
    Registered User
    Join Date
    02-25-2010
    Location
    Burnaby, BC, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    VB Macro, FOR loop with conditional formatting

    I have a complex sheet where rows are continuosly overwritten and new data needs to be formatted each time. My macro works great aside from the fact the conditional format formula expression adds double quotes rendering the conditional format useless. After running the macro I can go into the conditional format field, remove the quotes, and the formatting formula works as expected. So...I first did a "record macro" to grab the code for conditional formatting:

    Please Login or Register  to view this content.

    Note: $BK$1, $BK$2, & $BK$3 contain the reference text for the conditional format. At any time before or after the macro is run a person must be able to edit "BK14" and change the format accordingly. (Please don't question the logic of the reference text list, I am automating certain tasks in a beast of a workbook and the list plays a significant role)

    Here is my code to implement it in a FOR loop (shortened to one condition)...row number "14" in above is the variable:

    Please Login or Register  to view this content.

    So the formula is entered correctly into the conditional format area except a set or double quotes are put around the formula....removing quotes from the above code results in an incorrect formula, or a VB syntax error.

    I'm so darn close I just can't get rid of those quotes...help?
    Last edited by RMGreenlight; 03-02-2010 at 03:14 PM. Reason: I was told to correct as per forum rules.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VB Macro, FOR loop with conditional formatting

    Hi RM, welcome to the forum. Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to edit that post above, click Go Advanced and put code tags around that code you used.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-25-2010
    Location
    Burnaby, BC, Canada
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VB Macro, FOR loop with conditional formatting

    Solved my problem with a workaround.

    Instead of inputting the formula with variable into the conditional format code, I first write the formula's to some empty cells at the top of my sheet. Then in the conditional format statement I grab the values from those cells. No random quotes around the formula, problem solved.

    Thanks for trying.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1