Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Quotation in VBA (Excel 2000 SR-1)

    I have a formula to have the VBA code insert a formula to the worksheet.
    ="The Number is " & A1. However I am confused on how I can put the " into the VBA code. Since VBA use " as well.
    Thanks for any idea.
    p.s. My workaround is store the formula somewhere in the spreadsheet then let the VBA copy back.

  2. #2
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quotation in VBA (Excel 2000 SR-1)

    You could use the ascii code:
    chr$(34)

  3. #3
    New Lounger
    Join Date
    Mar 2001
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quotation in VBA (Excel 2000 SR-1)

    Thanks, It works.
    By the way,What is the ascii code means?

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quotation in VBA (Excel 2000 SR-1)

    Just use two quotes for each one you want in the result like this:

    <pre>="""The number is """ & A1
    </pre>


    If you really meant you are using VBA to insert that formula, then you would need something like this:

    <pre> ActiveSheet.Range("B1").Formula = "=""""""The number is """"""&A1"
    </pre>

    Legare Coleman

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Quotation in VBA (Excel 2000 SR-1)

    <A target="_blank" HREF=http://webopedia.internet.com/TERM/A/ASCII.html>Webopedia</A> has a definition of ascii.

    In this case, a double quote character is stored as a bit pattern, which I can represent in code as CHR(34).
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Posting Permissions

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