+ Reply to Thread
Results 1 to 9 of 9

While Loop Object Error

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    While Loop Object Error

    I am attempting to point excel at a named cell, fill that cell with a number, and then select the cell to the right of the active cell in the same row, and fill that cell with number + 1, until the loop is closed. When my Macro runs, I receive the "Object Required" error message.

    Please Login or Register  to view this content.
    Greatly appreciate any help.
    Last edited by Ascension; 10-04-2010 at 03:00 PM.

  2. #2
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: While Loop Object Error

    I believe as a first step I was not correctly addressing the two named references, which I think I fixed. EndingMonth is an output cell of a formula and contains the number which I want to use as iterations of the macro, and FirstMonthHeading is the first cell I want a value in (A value of 1).


    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: While Loop Object Error

    Your syntax for the offset is slightly wrong, and there's no need to use the FormulaR1C1 property or to select each cell in turn...

    Please Login or Register  to view this content.

    That should work, provided both the named ranges exist.

  4. #4
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: While Loop Object Error

    I used the code, there was one slight issue as the named range was FirstMonthHeading instead of FirstMonthEnding, but it returned a 400 error as well. Even if I hardcode in a value instead of Ending, it won't run the macro.

  5. #5
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: While Loop Object Error

    I believe the error has something to do with the way Ending is defined, as when I comment that out and hardcode a value it runs fine.

  6. #6
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: While Loop Object Error

    I can confirm the only issue is that I can't suck the value of EndingMonth into Ending. I've refrenced it a bunch of different ways and can't get it to work.

    Please Login or Register  to view this content.
    If instead I say Ending = 12, it runs perfectly. What is the issue? The referenced cell is just a SUM function and displays a number.

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: While Loop Object Error

    No idea what the problem is - I've created a workbook with the exact code I posted in and it runs fine, even when I put a formula in the EndingMonth cell.

    Try this, if your FirstMonthHeading cell is A1 and, say, your EndingMonth is in B2 use the code...

    Please Login or Register  to view this content.
    Change the ranges and the sheet numbers to match the format of your workbook and see if that works. If it does then there's something up with the way you've named the ranges.

  8. #8
    Registered User
    Join Date
    09-28-2010
    Location
    Boston, MA
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: While Loop Object Error

    That's it! Thank you so much, I just deleted the old name and made a new one, popped it in and it worked great.

  9. #9
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: While Loop Object Error

    Good stuff, just one of those things I guess. Glad you got it working.

+ 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