+ Reply to Thread
Results 1 to 15 of 15

Serpentine numbers in a table formula

  1. #1
    Registered User
    Join Date
    04-21-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Serpentine numbers in a table formula

    I have tried to google 'how to serpentine numbers excel formula' without any luck. I also replaced serpentine with zigzag and did not receive the results I was looking for.

    This will be used as a field map for research plots on a experimental farm. I'm a student please help.

    I want to use a formula to add numbers sequentially to a table in a serpentine manner (see below and/or attachment). Basically, the numbers will begin normally and use excels automatic function (1, 2, 3, etc...-->). Afterwards, the numbers should continue to add numbers sequentially on the next row, except in the reverse order (<--...etc, 13, 12, 11).

    1 2 3 4 5 6 7 8 9 10
    20 19 18 17 16 15 14 13 12 11
    21 22 23 24 25 26 27 28 29 30
    40 39 38 37 36 35 34 33 32 31

    I hope this makes sense and thank you in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Serpentine numbers in a table formula

    One way, copied down:

    =IF(ISODD(ROWS(A$9:A9)),INDEX(SEQUENCE(4,10,1,1),ROWS(A$9:A9)),INDEX(SEQUENCE(4,10,40,-1),5-ROWS(A$9:A9)))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Serpentine numbers in a table formula

    in A1

    =IF(ISEVEN(ROW()),(ROWS($1:1)*10)-COLUMN(A$1)+1,(ROWS($1:1)-1)*10+COLUMN(A$1))

    Copy across to J then down

    Change 10 to desired number of columns
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Serpentine numbers in a table formula

    Another option if you have the Lambda function
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    where B1 is the number of rows & B2 the number of columns
    Attached Files Attached Files

  5. #5
    Forum Contributor John Vergara's Avatar
    Join Date
    01-17-2022
    Location
    Colombia
    MS-Off Ver
    365
    Posts
    200

    Re: Serpentine numbers in a table formula

    Hi to all!

    Another option could be:
    PHP Code: 
    =SEQUENCE(4,10)+{0;1;0;1}*SEQUENCE(,10,9,-2)) 
    in a general way (using Fluff file):
    PHP Code: 
    =SEQUENCE(B1,B2)+ISEVEN(SEQUENCE(B1))*SEQUENCE(,B2,B2-1,-2
    Blessings!
    Last edited by John Vergara; 04-21-2022 at 12:18 PM.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Serpentine numbers in a table formula

    Forgot to change part of the formula to make it dynamic.
    It should be
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-13-2018
    Location
    Istanbul
    MS-Off Ver
    Microsoft 365
    Posts
    91

    Re: Serpentine numbers in a table formula

    Hello & Welcome to forum

    Could this work for you? You would need to copy it for every new row.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-21-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Re: Serpentine numbers in a table formula

    Thank you all for the quick reply. These are all really good answers.

    I think this formula will work for my immediate purposes. See attachment Sheet2.
    =SEQUENCE(B1,B2)+ISEVEN(SEQUENCE(B1))*SEQUENCE(,B2,B2-1,-2)
    However, I really wanted to get this code to work; as I could manipulate other files that are already made. See attachment Sheet1.
    =J1+IF($A1=MAX($A1:$J1),(J$1*2-1),20-(J$1*2-1))
    The problem with this formula is the [value if true] and [value if false] statements in the IF formula. This formula is based on my generalized table beginning with the number 1. However, the sample numbers will never begin with 1 (more likely 1001). Likewise, most fields will not be that simple; some may have 15 rows and 23 columns, or any number.
    I'm trying to adjust the formula to continue the serpentine sequential numbers, regardless of the beginning number and/or number of rows or columns.

    I have another problem, but isn't critical. These answers are replying to my example table that begins in the top left and proceeds top to bottom. However, I was just informed that it is standard practice in field research to begin in the bottom left and proceed bottom to top (See attachment Sheet3). I can reverse order the tables (See attachment Sheet4 and formula below), but I would like it if I didn't need the extra step.
    =SORTBY($A$1:$J$4,ROW(A1:A4),-1)
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: Serpentine numbers in a table formula

    Using sheet3 & the formula I suggested you can sort it like
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor John Vergara's Avatar
    Join Date
    01-17-2022
    Location
    Colombia
    MS-Off Ver
    365
    Posts
    200

    Re: Serpentine numbers in a table formula

    Hi again!

    I put two new options, with your new requirements.
    Option 1 - Dynamic arrays
    PHP Code: 
    =SEQUENCE(C2,C3,C4+C2*C3-1,-1)-ISEVEN(SEQUENCE(C2))*SEQUENCE(,C3,C3-1,-2
    Option 2 - Old school formulas
    PHP Code: 
    =IF(OR(ROWS(B$7:B7)>$C$2,COLUMNS($B7:B7)>$C$3),"",$C$4+$C$3*($C$2-ROWS(B$7:B7))+IF(ISEVEN(ROWS(B$7:B7)),COLUMNS($B7:B7)-1,$C$3-COLUMNS($B7:B7))) 
    This option drag it down and right. Check file. Blessings!
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Serpentine numbers in a table formula

    A tweak to the one you posted above, removing the need to hard-code the size of your table. Put this in A2 of the file you uploaded in post #8 and fill across/down:

    =IF($A1=MAX($A1:$J1),$A1+COLUMNS($A1:A1),$J1+COLUMNS(A1:$J1))

    Works whether you are going up or down (obviously if starting at the bottom then you would change the 1s to 3s if putting in A2, but you can copy it easily enough)

  12. #12
    Registered User
    Join Date
    11-13-2018
    Location
    Istanbul
    MS-Off Ver
    Microsoft 365
    Posts
    91

    Re: Serpentine numbers in a table formula

    Hi. I think Nick's tweak will do the job.

    My current formula has certain limitations, such as starting number must be 1 and table must be at 10 cell width. Admittedly I did work on the example you provided, but it is entirely possible to remove those limitations with COUNT and maybe COLUMN. I have to work on it, but my home computer doesn't have Excel to I can only take a look tomorrow.

    That is unless someone else doesn't do it till then

  13. #13
    Registered User
    Join Date
    11-13-2018
    Location
    Istanbul
    MS-Off Ver
    Microsoft 365
    Posts
    91

    Re: Serpentine numbers in a table formula

    Hello again!

    Here's the reworked version of the formula. You still have 2 limitations: 1) you have to enter the first row of values manually, since there would be no way of knowing where, what, and whether descending or ascending order the beginning numbers will be, and 2) when you copy the formula for a new data, you need to manually adjust the formula references. Like for example if your data is from C to F, you need to change the A:D references in the formula to C:F. You would only need to do this in 1 cell, because when copied to the rest of the data it will arrange itself.

    I have presented some examples in the attached file. Please check & let me (or us ) know if that works!

    Regards
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    04-21-2022
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    3

    Re: Serpentine numbers in a table formula

    Wow, thank you very much; you people are awesome.

    I really like Nicks solution, as its a formula I can use in any excel sheet. However, MGC's solution works great for starting a new file.

    I find it hard to believe that I was unable to search for a solution on the internet. Field research has been using this serpentine method forever. There are some software packages that will create field maps automatically. This software will allow 'serpentine' or 'typewriter' sequential numbering. These software also allow you to start in any position (Top or Bottom; Left or Right). We don't have the budget for additional software and excel should have an easier solution for this problem. Anyways, thank you so much for all your help

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Serpentine numbers in a table formula

    Personally, I'd go with John V's. That's where I was trying to go.

    In any event....

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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: 4
    Last Post: 08-10-2021, 10:09 AM
  2. Power Query formula - Sum numbers in another table
    By bongielondy in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 04-14-2021, 07:50 AM
  3. using excel VBA find and higlight in red all prime numbers in a table of numbers
    By TeraFumba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2017, 07:30 AM
  4. Replies: 4
    Last Post: 10-11-2016, 01:51 PM
  5. Replies: 3
    Last Post: 12-14-2015, 01:21 PM
  6. I need a formula to show if a value is between two numbers on a table
    By Badboyz010 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-16-2013, 08:02 PM
  7. Formula for sorting table by numbers
    By Alleen86 in forum Excel General
    Replies: 4
    Last Post: 08-22-2010, 10:16 AM

Tags for this Thread

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