+ Reply to Thread
Results 1 to 8 of 8

Array of cell row numbers based on first occurrences

  1. #1
    Registered User
    Join Date
    10-11-2021
    Location
    Lufkin, Texas
    MS-Off Ver
    365
    Posts
    5

    Array of cell row numbers based on first occurrences

    Hello again excel community!

    I manage a spreadsheet that calculates various metrics off of tasks ordered by row and pertaining to specific order numbers. Due to their being multiple tasks per order number, someone decided it was a good idea to copy the total order hours into each tasks row for the order it pertains to.

    Now, I need to somehow sum up all the hours for all tasks however I cannot simply use the sum command since almost all the hours are repeated in multiple rows.

    Specifically, I need a formula that will create an array of all row numbers containing the first occurrences of every order number. That a way I can use the index formula to retrieve the hours and simply sum them up.

    I tried using the SMALL function however due to the large number of orders the spreadsheet became over saturated with formulas.
    I also tried using ROW with UNIQUE as the target however ROW doesn't seem to be able to handle arrays. If it did champagne would rain from the heavens. Lol.

    Any help would be appreciated.

    Thanks,

    excelhelp.jpg

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,909

    Re: Array of cell row numbers based on first occurrences

    Is there always an empty row above it?

  3. #3
    Registered User
    Join Date
    10-11-2021
    Location
    Lufkin, Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Array of cell row numbers based on first occurrences

    That is only a recent thing I'm afraid. When orders were first recorded by management they were stacked with no spaces for about the first 100,000 lines or so. Only within the last 2,000 limes did they start doing that. (easier for them to sort mentally I guess)

  4. #4
    Forum Expert
    Join Date
    09-30-2019
    Location
    Chiangmai, Thailand
    MS-Off Ver
    Office 2016, Excel 2019
    Posts
    1,234

    Re: Array of cell row numbers based on first occurrences

    I can only get sum of value, not an array. T_T

    Regards.
    Attached Images Attached Images

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Array of cell row numbers based on first occurrences

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Array of cell row numbers based on first occurrences

    if you are looking for the rows to sum then, given O365, you could use something like below:

    =SUM(FILTER(C2:C1001,A2:A1001<>A1:A1000))
    or
    =LET(a,CHOOSE({1,2},A2:A1001,C2:C1001),SUM(INDEX(UNIQUE(a),0,2)))

    same principle can be applied if you really need the actual rows, i.e.:

    FILTER(ROW(A2:A1001),(A2:A1001<>A1:A1000))

    all of the above assume first row of data is row 2; modify ranges per real-life requirements

  7. #7
    Registered User
    Join Date
    10-11-2021
    Location
    Lufkin, Texas
    MS-Off Ver
    365
    Posts
    5

    Re: Array of cell row numbers based on first occurrences

    Thank you- this is now solved - with a bit of tweaking!

    The formula you provided was also returning rows with blanks. I added a filter to remove those results. I also replaced the ranges with the column titles since these are in tables (Makes it stupid easy for management when all they have to do when they run out of rows is drag the end of the table down)

    See attached image and excel sheet.

    Thanks again!

    Attachment 774445
    Attached Files Attached Files

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

    Re: Array of cell row numbers based on first occurrences

    Ah, too slow. If data in F36:F46 for example I had:

    =MATCH(FILTER(UNIQUE(F36:F46),UNIQUE(F36:F46)<>""),F:F,0)

    Feels like there should be a way to exclude blanks built in to the UNIQUE function, it always feels messy using FILTER.

+ 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] Restrict cell value based on the number of occurrences of a value in a range
    By Luis Ah-Hoy Jr. in forum Excel General
    Replies: 5
    Last Post: 06-08-2017, 04:02 AM
  2. Loop through list, add to Array, count number of occurrences, clear array
    By HalPlz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-11-2016, 09:42 PM
  3. To find the number of occurrences based on the cell condition and retrieve the value
    By rsundarmail77 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-02-2011, 11:50 AM
  4. Replies: 11
    Last Post: 11-23-2011, 04:39 AM
  5. Macro to rename sheet based on date in a cell with multiple occurrences.
    By timlocke in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-12-2011, 03:08 PM
  6. Count occurrences of any numbers within a cell
    By Jamey in forum Excel General
    Replies: 2
    Last Post: 12-15-2010, 01:01 PM
  7. Count occurrences in an array
    By stavdav in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-16-2010, 08:28 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