+ Reply to Thread
Results 1 to 4 of 4

Object required error in a loop

  1. #1
    Registered User
    Join Date
    05-21-2007
    Posts
    79

    Object required error in a loop

    Is there something immediately wrong with this code?

    Please Login or Register  to view this content.
    I just want to figure out how many rows are filled at the top of my active sheet, so I can put something beneath them.

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Or try
    Please Login or Register  to view this content.
    in place of the loop


    Col
    Last edited by colofnature; 05-29-2007 at 10:39 AM.
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Please Login or Register  to view this content.
    I put in brackets to show what is happening. Your code asks to evaluate whether ActiveSheet.Cells(l,1).Value Is Nothing. Nothing and Is are used only with objects, but Cells.Value is a value ( Double, String, Boolean or Error), not an object. That's where the error came from.

    You may want
    Please Login or Register  to view this content.
    which is the same as
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-21-2007
    Posts
    79
    colofnature: Your first solution worked, to use = Empty instead of Is Nothing. However, your second solution (which I like the looks of) gives me an Overflow error. I don't know why, or how to fix it, but that's what it does.

    I'm okay with leaving it the way that works. My code is littered with loops, as they're the only way I know how to get the results I want, so one more won't hurt.

    EDIT: I figured it out. Using g as an integer, when the Row property returns a long. Thanks for the fix!
    Last edited by yellephant; 05-29-2007 at 12:25 PM.

+ 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