+ Reply to Thread
Results 1 to 4 of 4

For Next Loop adds an extra #N/A?

  1. #1
    Registered User
    Join Date
    08-16-2007
    Posts
    50

    For Next Loop adds an extra #N/A?

    Hello all,
    I'm testing the function of a simple for next loop. I manually put the values 1 through 10 in cells A1 to A10, then I am running a test macro to place the values from A1:A10 into C1:C10, C11:C20, and C21:C30. My code works, but it also puts "#N/A" in cell C31. My example code is below. Does anyone know why it's adding the #N/A?
    Thanks
    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: For Next Loop adds an extra #N/A?

    Hi, mcclanat,

    Please Login or Register  to view this content.
    makes it 11 instead of 10, 21 not 20, 31 not 30.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-16-2007
    Posts
    50

    Re: For Next Loop adds an extra #N/A?

    That makes sense. Thanks!

    Out of curiosity, why do you set the ranges to nothing at the end?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: For Next Loop adds an extra #N/A?

    Hi, mcclanat,

    sort of cleaning up at the end of what I set up before. According to MS the scope of the variables should end with the end of the procedure but if you work with another Office program not setting the objects to nothing might cause problems there. To avoid these I simply use the clean up in opposite order to the setting at the end (not resolving the objects in the proper order might cause other problems which I prefer not to have ).

    HTH,
    Holger

+ 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. [SOLVED] userform adds extra row whwn entering data
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-01-2013, 01:53 PM
  2. Replies: 6
    Last Post: 06-12-2012, 07:50 AM
  3. Replies: 2
    Last Post: 12-14-2010, 10:20 AM
  4. Help!! MailMerge Adds hidden extra page
    By petreli in forum Word Formatting & General
    Replies: 1
    Last Post: 12-14-2009, 08:55 AM
  5. special formatting adds extra zeroes
    By nosnil14 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-01-2006, 11:55 AM

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