+ Reply to Thread
Results 1 to 3 of 3

Error with formula in VBA

  1. #1
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Error with formula in VBA

    Greetings, Gurus.

    In the code snippet below, I have previously set variables for "Ans" and "Ans1", and the user has already entered the values:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    That part works fine in performing the necessary calculations. My problem is, when trying to enter a "statement" at the top of the page, near the end of the macro, all I am getting is "#NAME?" as a result. Here is the formula I am entering via VBA. Can anyone see the problem with this formula?

    Please Login or Register  to view this content.
    Also, how would I break this long formula up into two lines of VBA, just to make the code neater? I've seen " _" used, I thought, to break a single line of code into two lines, but it hasn't worked for me.

    Thanks in advance for any help you can offer.

    Hutch
    Last edited by hutch@edge.net; 05-08-2009 at 08:47 PM.

  2. #2
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Error with formula in VBA

    Hutch,

    The problem lies in your quotes. The #NAME error is being caused because the formula is showing your VBA variables instead of their values. And I think your line splits (_) are having issues because they are in the middle of a string (must be at the end of a string).

    Here is my version of your formula (with a bunch of line splits just 'cause)

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: Error with formula in VBA

    Beautiful! Works like a charm.

    Keeping up with the number of quotes always confuses me.

    Thanks, Chance!

    Have a good one.

+ 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