+ Reply to Thread
Results 1 to 2 of 2

help writing formula

  1. #1
    Ryan Proudfit
    Guest

    help writing formula

    The current formula residing in about 200 cells is

    ='Daily N '!AN13

    I'm trying to write a macro that will change that formula to

    =IF(OR(B9=6,B9=7),"",'Daily N '!AN13)

    Here is my code

    ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" & ActiveCell.Row &
    "=7),""," & strHoldFormula & ")"

    My problem is

    "=7),"","

    Since quotes are used to identify the beginning and end of a text string
    within a formula, how do you use quotes within a formula to tell Excel to
    display nothing if a condition is true?

    --
    Ryan Proudfit

  2. #2
    Chip Pearson
    Guest

    Re: help writing formula

    To include a " character in a VBA string, use two " characters.
    E.g.,

    ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" & _
    ActiveCell.Row & "=7),""""," & strHoldFormula & ")"


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Ryan Proudfit" <RyanProudfit@discussions.microsoft.com> wrote in
    message
    news:A8D7714B-372E-4233-8B75-E924207FFBF7@microsoft.com...
    > The current formula residing in about 200 cells is
    >
    > ='Daily N '!AN13
    >
    > I'm trying to write a macro that will change that formula to
    >
    > =IF(OR(B9=6,B9=7),"",'Daily N '!AN13)
    >
    > Here is my code
    >
    > ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" &
    > ActiveCell.Row &
    > "=7),""," & strHoldFormula & ")"
    >
    > My problem is
    >
    > "=7),"","
    >
    > Since quotes are used to identify the beginning and end of a
    > text string
    > within a formula, how do you use quotes within a formula to
    > tell Excel to
    > display nothing if a condition is true?
    >
    > --
    > Ryan Proudfit




+ 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