+ Reply to Thread
Results 1 to 10 of 10

Fill range with incremental numbers

  1. #1
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106

    Fill range with incremental numbers

    This should be very simple thing, but I can't figure out what I do wrong.
    The idea is to get for some range (size/location doesn't matter) to fill it's cell with numbers from 1 to number of cells, but it doesn't seem to work.

    Please Login or Register  to view this content.
    The result from this module "as is" is that each cell gets number 36 (9x4, count of cells). What do I have wrong here?
    Last edited by Jaymond Flurrie; 07-25-2008 at 07:01 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Jaymond Flurrie,

    You can do this a couple of ways. The easiest way is to use the For Each Next loop. This will automatically index through all objects in the collection, in this case your range rng.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485
    Hi,
    Maybe this
    Please Login or Register  to view this content.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Here's a non-looping method
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Jaymond,

    I would have close this thread if I had seen it first. Please read the Forum Rules about thread titles before starting your next one.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,485
    Quote Originally Posted by shg
    Jaymond,

    I would have close this thread if I had seen it first. Please read the Forum Rules about thread titles before starting your next one.
    Well, good for you!!!

  7. #7
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106
    Quote Originally Posted by mikerickson
    Here's a non-looping method
    Please Login or Register  to view this content.
    I understood that this is pretty fast, right? I mean, it doesn't use loop and uses worksheet formulas, which both should be always used when possible, right?

    Quote Originally Posted by shg
    Jaymond,

    I would have close this thread if I had seen it first. Please read the Forum Rules about thread titles before starting your next one.
    So it should have been for example "Fill range with incremental numbers"? I will remember this next time. Sorry for bad title.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Jaymond,
    You will have to do some testing on typical ranges for your needs.
    Normally loops are slower, but array formulas are notoriously very slow. I tried to minimize the size of the arrays involved, but your testing would be the best judge.

  9. #9
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106
    Quote Originally Posted by mikerickson
    Jaymond,
    You will have to do some testing on typical ranges for your needs.
    Normally loops are slower, but array formulas are notoriously very slow. I tried to minimize the size of the arrays involved, but your testing would be the best judge.
    Does it depend about CPU at all? I mean, does dual-core count something faster than "classic" CPU?

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Quote Originally Posted by Jaymond
    So it should have been for example "Fill range with incremental numbers"?
    That would have been much better, thank you.

    The objective is to create a searchable database. In addition, I think you'll find that people are more willing to look at, and respond to, threads that have a concise title and well-stated problem.

+ 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