+ Reply to Thread
Results 1 to 7 of 7

Adding Formnula in VBA - Run-time Error 13

  1. #1
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Adding Formnula in VBA - Run-time Error 13

    Hi all,

    I ran into a snag, and I have been trying to resolve this on my own most of the day.... unsuccessfully. I do not understand why this is happening. Attached are 2 screenshots showing the error and where within the code. The code is below as well as within the sample workbook. Thanks in advance!

    Please Login or Register  to view this content.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Webbers; 03-22-2021 at 05:50 PM. Reason: Forgot VBA in post
    ~*~ Sherry ~*~
    Poinciana, FL

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Adding Formnula in VBA - Run-time Error 13

    You need to double-up all the quotes inside the formula, like
    Please Login or Register  to view this content.
    Last edited by Fluff13; 03-22-2021 at 06:02 PM.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Adding Formnula in VBA - Run-time Error 13

    Hi Webbers,

    We've all struggled with this formula to VBA problem. Here is my solution. Make the formula work in the Excel sheet itself, then copy the formula using the keyboard buffer.
    Then move to VBA and to the Dot Formula = part first. Then put a quote and paste the formula and a quote at the end.
    I see you missed the ...formula = "= .... in your picture above.
    Then for every quote you have in your formula make it a double quote.
    https://docs.microsoft.com/en-us/off...ng-expressions

    Hope that helps. If not then keep asking.
    Last edited by MarvinP; 03-22-2021 at 06:04 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Adding Formnula in VBA - Run-time Error 13

    Enter the formula in a cell
    Select the cell
    Tools, Macro, Record Or Developer - Record Macro (Give the macro a recognizable name here)
    F2, Enter
    Go into your module and your formula is there as a macro (including double upped quotation marks if needed.)

  5. #5
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Adding Formnula in VBA - Run-time Error 13

    Quote Originally Posted by Fluff13 View Post
    You need to double-up all the quotes inside the formula, like
    Please Login or Register  to view this content.
    Fluff13,

    I looked at the formula for this line side by side with your corrected version to see where I went wrong. I was like "half-way" there basically, it seemed in the areas where I has a space and dash, I used only single quotes rather than the double quotes there too. I have learned a lot since you helped me with this the very 1st time and I did not use double quotes at all. Thanks so much!!!!
    Last edited by Webbers; 03-23-2021 at 11:28 AM.

  6. #6
    Forum Contributor Webbers's Avatar
    Join Date
    09-06-2005
    Location
    Poinciana, FL
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    337

    Re: Adding Formnula in VBA - Run-time Error 13

    Thank you @MarvinP and @jolivanes!

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Adding Formnula in VBA - Run-time Error 13

    Glad to help & thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. adding time from 2 cells in 3rd cell=#VALUE error
    By Mr.GfCs in forum Excel General
    Replies: 1
    Last Post: 04-23-2020, 02:38 AM
  2. [SOLVED] Why am I Getting a Run-time Error '91' error after adding CurrentUser to code below?
    By gmr4evr1 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 06-14-2015, 06:24 PM
  3. run time error adding values to worksheet
    By sabrinamay16 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2013, 01:18 PM
  4. Excel 2007 : #VALUE! error when adding time
    By jhendrix in forum Excel General
    Replies: 3
    Last Post: 01-15-2010, 07:14 PM
  5. Run time error 1004 when adding rows
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2009, 07:35 AM
  6. [SOLVED] Run time error '-2147467259 (80004005) adding icon
    By DMc2005 in forum Excel General
    Replies: 3
    Last Post: 10-02-2005, 12:05 PM
  7. Run time error '-2147467259 (80004005) adding icon
    By DMc2005 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-02-2005, 12:05 PM

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