+ Reply to Thread
Results 1 to 13 of 13

Excel Function to number in a snake order

  1. #1
    Registered User
    Join Date
    02-11-2014
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    5

    Excel Function to number in a snake order

    Any help would be appreciated. I currently have a drop down menu, 1-12, and a list or column of names that I would like excel to number (in column B) depending on the selected drop down. For example, I select 5 from the dropdown menu. Next to the first column (Column B) , I would like it to number in the following order: 1,2,3,4,5,2,3,4,5,1,3,4,5,1,2 ... until all the names from column A are numbered. Does anyone have an idea on how to do this? Or the Formula I would use? Thanks in advance.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Excel Function to number in a snake order

    Can you explain more in detail the sequence, because name "snake order" more often means 1 2 3 4 5 5 4 3 2 1 1 2 3 and so on.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-11-2014
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Function to number in a snake order

    sure, So in my column A, I will have say 100 accounts. From my drop down menu select I will put it in 5 groups. I want it to order or number like this:

    Ex with 5

    A - 1
    B - 2
    C - 3
    D - 4
    E - 5
    F - 2
    G - 3
    H - 4
    I - 5
    J - 1
    K - 3
    L - 4
    M - 5
    N - 1
    O - 2
    P - 4
    Q - 5
    ...

    I may have used the wrong term with "snake order." I just need it to order in a pattern such as above with the selected drop down menu. If it is 4, then I need the pattern to be 1,2,3,4,2,3,4,1,3,4,1,2...

    Thanks in advance for any help.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Excel Function to number in a snake order

    if your drop down is connected with cell F1, write in B2 (or wherever you want to start):
    =TRUNC(MOD((ROW(1:1)-1)*(F$1+1)/F$1,F$1)+1)
    and copy down.

    the key to the trick is multiplying row number (1, 2, 3 etc.) by
    (n+1)/n

    if you (one) wonder how it works - start with
    =ROW(1:1)-1
    then add next steps - watch this one in particular:
    =(ROW(1:1)-1)*(F$1+1)/F$1
    and then
    =MOD((ROW(1:1)-1)*(F$1+1)/F$1,F$1)

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Excel Function to number in a snake order

    PS. Typical snake formula would be:

    =MIN(MOD(ROW(1:1)-1,2*F$1)+1,2*F$1-MOD(ROW(1:1)-1,2*F$1))

    Again - max in F1. Formula anywhere and copy down.
    Attached Files Attached Files
    Last edited by Kaper; 02-11-2014 at 01:01 PM.

  6. #6
    Registered User
    Join Date
    02-11-2014
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Function to number in a snake order

    Worked perfectly. Thank you for your help, this has been giving me major trouble

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

    Re: Excel Function to number in a snake order

    =TRUNC(MOD((ROW(1:1)-1)*(F$1+1)/F$1,F$1)+1)

    What in the world is the purpose of a sequence like that, Kaper?
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Excel Function to number in a snake order

    Hi shg
    If you are asking about excel side - I am ready to explain,

    but if about merit - good question, but rather not to me but to Shudodger

    basically for any n it produces
    1
    2
    .
    .
    .
    n-1
    n
    2
    3
    .
    .
    n-1
    n
    1

    3
    4
    .
    .
    n
    1
    2


    ....

    n-1
    n
    1
    .
    .
    n-3
    n-2


    etc.

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

    Re: Excel Function to number in a snake order

    I understand the formula, I just can't imagine a purpose.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel Function to number in a snake order

    wouldnt
    =MOD(ROW(A1)-1,$G$1)+1 where g1 is dropdown and formula put in first row of data in col b do?
    Attached Files Attached Files
    Last edited by martindwilson; 02-11-2014 at 02:21 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  11. #11
    Registered User
    Join Date
    02-11-2014
    Location
    Louisiana
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Function to number in a snake order

    Thank you Kaper, it is exactly what I needed.

  12. #12
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: Excel Function to number in a snake order

    Hi martindwilson,

    I wouldn't say your formula would do.
    It is just returning the same sequence without shift after each full set.

    Write 1 in B2
    Then formula for B3:

    Please Login or Register  to view this content.
    and copy down.

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel Function to number in a snake order

    Ok i re read the original and see what you mean sems a strange requirement tho

+ 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] VBA to detect change in order number, then add a value to each 1st line of that order
    By Marijke in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2013, 09:19 AM
  2. Snake columns according to cell value instead of row number
    By jassybunny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2012, 08:13 AM
  3. Snake Count for Fantasy Football
    By Pauleyb in forum Excel General
    Replies: 3
    Last Post: 08-30-2011, 05:43 PM
  4. purchase order list & order number generator
    By podaf in forum Excel General
    Replies: 2
    Last Post: 06-28-2009, 06:02 PM
  5. [SOLVED] Make Excel 2000 print long narrow list "snake" on wide paper?
    By steve from mw rms rrd in forum Excel General
    Replies: 2
    Last Post: 03-01-2006, 03:30 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