+ Reply to Thread
Results 1 to 10 of 10

SUM function with variable end range -- "#NAME?" error

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    SUM function with variable end range -- "#NAME?" error

    Hello, so I'm working on this bit of code and the whole thing gave me an error so I started blocking it off line by line to find out what exactly is going on. The last line that isn't a comment ( with the SUM function -- "activecell.value = "=(SUM(B2: endrow) -1 ) / (10-1)" )

    So that line is giving me a "#NAME?" error in the cell I'm putting that formula in. I imagine it has something to do with my syntax with the variable. Any suggestions? Thanks!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: SUM function with variable end range -- "#NAME?" error

    As an fyi, you don't need to comment out your code when you can step through each line individually by pressing F8. It's a huge time saving tip in my opinion and I was very happy to learn that early on in my coding career.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: SUM function with variable end range -- "#NAME?" error

    try
    Please Login or Register  to view this content.
    You can't use endrow in quotations because the VBE sees everything within quotes as a string type so you have to separate the string and insert the range between the quotes. I don't know if this will solve your problem but it's a start.

  4. #4
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: SUM function with variable end range -- "#NAME?" error

    Thanks for the tip!

  5. #5
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: SUM function with variable end range -- "#NAME?" error

    Hmm...now it's just giving me a 400 error.

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: SUM function with variable end range -- "#NAME?" error

    maybe
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: SUM function with variable end range -- "#NAME?" error

    Nicholas,

    The problem is in fact in your syntax. In the following line:
    Please Login or Register  to view this content.
    All of the data between the "quotation marks" will be treated as text, including the word "endrow". Try changing it to something like:

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: SUM function with variable end range -- "#NAME?" error

    Hi BigBas the line
    Please Login or Register  to view this content.
    has an extra " and should be
    Please Login or Register  to view this content.
    Last edited by Mordred; 06-12-2013 at 12:11 PM.

  9. #9
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: SUM function with variable end range -- "#NAME?" error

    Replied before refreshing -- I'm trying the new solution.
    Last edited by NicholasL; 06-12-2013 at 12:21 PM.

  10. #10
    Registered User
    Join Date
    06-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    64

    Re: SUM function with variable end range -- "#NAME?" error

    The code you suggested worked! Thank you very much, both of you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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