+ Reply to Thread
Results 1 to 6 of 6

increment numbers

  1. #1
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    increment numbers

    Hi All

    I am trying to write a code in command button if i click it should give values 1 to 10 in a1 to a10
    but my code gives only 10 for all cells. can you please tell whats wrong in this code

    many thanx


    Please Login or Register  to view this content.
    Never confuse a single defeat to the final defeat.

  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,197

    Re: increment numbers

    Hi, grkchakri,

    what about
    Please Login or Register  to view this content.
    You have a second loop inside the first one and only the last value is visible on these cells.

    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
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: increment numbers

    You have a loop within a loop
    The outer loop runs from a1:a10
    The inner loop runs from 1 to 10
    So the final result in each cell a1:a10 will be 10 since thats the last value of the inner loop

    Maybe this
    Please Login or Register  to view this content.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  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,197

    Re: increment numbers

    Hi, grkchakri,

    if you prefer to use the For...Each loop:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: increment numbers

    Generally, when writing to the worksheet it is better to put the answer in an array and then just write once. However, this will meet your requirement.

    Please Login or Register  to view this content.
    Regards,
    Tom

    If my answer resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post
    .

  6. #6
    Forum Contributor
    Join Date
    02-12-2011
    Location
    Hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    261

    Re: increment numbers

    Thank-you.jpg

    Hahobe, special k

+ 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] Automatically Increment Numbers Between Worksheets
    By shawnashawna in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-11-2013, 11:01 PM
  2. Increment Numbers
    By Tashia in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-04-2008, 02:00 PM
  3. round UP numbers in half increment.
    By dannyboy213 in forum Excel General
    Replies: 1
    Last Post: 08-30-2006, 04:26 PM
  4. [SOLVED] Auto Increment Rows in between numbers
    By D in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2005, 01:06 PM
  5. [SOLVED] increment/populate numbers by worksheet
    By br549 in forum Excel General
    Replies: 3
    Last Post: 01-04-2005, 06:06 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