+ Reply to Thread
Results 1 to 3 of 3

Application-defined or object-defined error in VBA

  1. #1
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Application-defined or object-defined error in VBA

    It appears this line of code is giving me an application-defined or object-defined error:

    Please Login or Register  to view this content.
    This is what the entire subroutine looks like:

    Please Login or Register  to view this content.
    It's intentions are simple. Given column A1 looks like this:

    1
    2
    3
    4
    1
    2
    3

    Whenever I hit a number, where the next number starts over again, I just want to copy that last number to the next column:

    1 4
    2 4
    3 4
    4 4
    1 3
    2 3
    3 3

    My code should be doing this, but I am stuck because I don't know why this application-defined error is occurring.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,601

    Re: Application-defined or object-defined error in VBA

    You have initialized iCounter and Start to zero, then you use: Cells(start, iCounter).Values = curVal which is: Cells(0, 0).... There's no such cell; no row zero, no column zero.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: Application-defined or object-defined error in VBA

    It appears you were right. I just had to initialize the variables to 1 rather than 0. I was assuming the table was 0-indexed based.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 05-08-2014, 04:57 AM
  2. Previously working code is now is now giving Application-defined or object-defined error
    By ready2learn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2014, 07:22 PM
  3. [SOLVED] application-defined/object-defined error 1004 when trying to read from or write to cells
    By florin_excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 08:38 AM
  4. Replies: 2
    Last Post: 09-12-2012, 01:01 PM
  5. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  6. Application-defined or object-defined error with unshare/share macro
    By rlw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2007, 07:58 AM
  7. Replies: 3
    Last Post: 07-24-2006, 08:20 PM

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