+ Reply to Thread
Results 1 to 4 of 4

Using Quotation Marks in Arguments

  1. #1
    Dawg House Inc
    Guest

    Using Quotation Marks in Arguments

    I have three option buttons, and pending on which one is selected, I need to
    update three related cells with the appropriate formula. I have this
    currently, but its not working properly:

    Worksheets("S1").Range("C3").Value = "=IF(South!G16 = "", "", South!G16)"
    Worksheets("S1").Range("C5").Value = "=IF(MidWest!G16 = "", "", MidWest!G16)"
    Worksheets("S1").Range("C7").Value = "=IF(West!G16 = "", "", West!G16)"

    This results in the formula in the cell ending up like this:
    =IF(South!G16 = ", ", South!G16)
    =IF(MidWest!G16 = ", ", MidWest!G16)
    =IF(West!G16 = ", ", West!G16)

    I WANT the result to be this:
    =IF(South!G16 = "", "", South!G16)
    =IF(MidWest!G16 = "", "", MidWest!G16)
    =IF(West!G16 = "", "", West!G16)

    Any suggestions would be greatly appreciated.
    --
    Dawg House Inc.
    "We live in it, therefore, we know it!"

  2. #2
    Tom Ogilvy
    Guest

    Re: Using Quotation Marks in Arguments

    Worksheets("S1").Range("C3").Value = "=IF(South!G16 = """", """",
    South!G16)"
    Worksheets("S1").Range("C5").Value = "=IF(MidWest!G16 = """", """",
    MidWest!G16)"
    Worksheets("S1").Range("C7").Value = "=IF(West!G16 = """", """", West!G16)"


    Often good to test in the immediate window:

    ? "=IF(West!G16 = """", """", West!G16)"
    =IF(West!G16 = "", "", West!G16)

    you need to double up on double quotes interior to a string.

    --
    Regards,
    Tom Ogilvy

    "Dawg House Inc" <[email protected]> wrote in message
    news:[email protected]...
    > I have three option buttons, and pending on which one is selected, I need

    to
    > update three related cells with the appropriate formula. I have this
    > currently, but its not working properly:
    >
    > Worksheets("S1").Range("C3").Value = "=IF(South!G16 = "", "", South!G16)"
    > Worksheets("S1").Range("C5").Value = "=IF(MidWest!G16 = "", "",

    MidWest!G16)"
    > Worksheets("S1").Range("C7").Value = "=IF(West!G16 = "", "", West!G16)"
    >
    > This results in the formula in the cell ending up like this:
    > =IF(South!G16 = ", ", South!G16)
    > =IF(MidWest!G16 = ", ", MidWest!G16)
    > =IF(West!G16 = ", ", West!G16)
    >
    > I WANT the result to be this:
    > =IF(South!G16 = "", "", South!G16)
    > =IF(MidWest!G16 = "", "", MidWest!G16)
    > =IF(West!G16 = "", "", West!G16)
    >
    > Any suggestions would be greatly appreciated.
    > --
    > Dawg House Inc.
    > "We live in it, therefore, we know it!"




  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493
    you need four quotes

    one way to code a formula, is to type it out on the spreadsheet like you normally do,

    then goto your macro recorder select the cell with the formula, press F2 and enter =>stop recording, look at the formula in VBA

  4. #4
    Dawg House Inc
    Guest

    Re: Using Quotation Marks in Arguments

    Thanks Tom. While that is very obvious, I stupidly tried """ instead of """".
    Thanks for your help. You guys are always there when I need it :-)
    --
    Dawg House Inc.
    "We live in it, therefore, we know it!"


    "Tom Ogilvy" wrote:

    > Worksheets("S1").Range("C3").Value = "=IF(South!G16 = """", """",
    > South!G16)"
    > Worksheets("S1").Range("C5").Value = "=IF(MidWest!G16 = """", """",
    > MidWest!G16)"
    > Worksheets("S1").Range("C7").Value = "=IF(West!G16 = """", """", West!G16)"
    >
    >
    > Often good to test in the immediate window:
    >
    > ? "=IF(West!G16 = """", """", West!G16)"
    > =IF(West!G16 = "", "", West!G16)
    >
    > you need to double up on double quotes interior to a string.
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Dawg House Inc" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have three option buttons, and pending on which one is selected, I need

    > to
    > > update three related cells with the appropriate formula. I have this
    > > currently, but its not working properly:
    > >
    > > Worksheets("S1").Range("C3").Value = "=IF(South!G16 = "", "", South!G16)"
    > > Worksheets("S1").Range("C5").Value = "=IF(MidWest!G16 = "", "",

    > MidWest!G16)"
    > > Worksheets("S1").Range("C7").Value = "=IF(West!G16 = "", "", West!G16)"
    > >
    > > This results in the formula in the cell ending up like this:
    > > =IF(South!G16 = ", ", South!G16)
    > > =IF(MidWest!G16 = ", ", MidWest!G16)
    > > =IF(West!G16 = ", ", West!G16)
    > >
    > > I WANT the result to be this:
    > > =IF(South!G16 = "", "", South!G16)
    > > =IF(MidWest!G16 = "", "", MidWest!G16)
    > > =IF(West!G16 = "", "", West!G16)
    > >
    > > Any suggestions would be greatly appreciated.
    > > --
    > > Dawg House Inc.
    > > "We live in it, therefore, we know it!"

    >
    >
    >


+ 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