+ Reply to Thread
Results 1 to 7 of 7

Range Selection Error

  1. #1
    Registered User
    Join Date
    06-05-2009
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    21

    Range Selection Error

    I am having some trouble with a variable range selection within a regression. I keep getting an "application-defined or object-defined error." I've isolated each statement to find that the code that is causing the regression not to work is below (the error for that line of code states that the Select method of Range class failed):

    Please Login or Register  to view this content.


    This is confusing because the following code works in a different module:

    Please Login or Register  to view this content.

    This is the full regression code for the one that is not working:

    Please Login or Register  to view this content.

    (regressionWindow = counter3 + 36)


    Thank you for any help you can offer on this issue
    Last edited by emadden; 06-09-2009 at 05:01 PM. Reason: solved

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Range Selection Error

    Hi Emadden,

    I think you may have some quotation marks in the wrong places. If counter3 is a variable defined in the macro, it needs to be outside any quotation marks, like so:
    Please Login or Register  to view this content.
    Hope that helps!

  3. #3
    Registered User
    Join Date
    06-05-2009
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Range Selection Error

    I tried your solution, and there is now a compilation error. I think that this is because of the proposed solution. I believe that Excel only allows you to have one set of quotation marks in a range selection. The code now looks like how yours is posted above:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Range Selection Error

    Hi Emadden,

    I've never used the regression tool in Excel, and certainly not using VBA, but the Range arguments can have many sets of quotation marks. For example, this works just fine:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-05-2009
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Range Selection Error

    Hahaha, thank you very much Paul, that last reply was actually the solution:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887

    Re: Range Selection Error

    Glad it worked out.

    Although, you shouldn't have to separate the : from the $A$ (or $D$) as long as you have the & between counter3 and that section. I noticed in your previous post that this & was missing - even though it was in my code - which would definitely cause a problem.

    Please Login or Register  to view this content.
    should work just as well as
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-05-2009
    Location
    U.S.
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Range Selection Error

    Yes, the way you originally had it does work. I changed it back to that to take out some of the concatenation, I just didn't realize the difference at first. Thanks again

+ 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