+ Reply to Thread
Results 1 to 4 of 4

Array formulae/macro? Counting datasets -

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-01-2010
    Location
    Southampton, England
    MS-Off Ver
    Excel 2007
    Posts
    303

    Array formulae/macro? Counting datasets -

    My knowledge of excel is mediocre/good, however when it comes to using array formulae I'm a little bit of an amateur. The problem I have is that I receive hundreds of datasets every day, it would be very useful to be able to count the size of these datasets (they range from 2 - 30 pieces of data in size.) Also I would like to return the size of the dataset in the same row where the data rank = 1. Note this is not always the top piece of data.

    It is best to take a look at the example spreadsheet provided.

    If anyone could provide any assistance it would be greatly appreciated.

    Merry Xmas

    Ad
    Attached Files Attached Files

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Array formulae/macro? Counting datasets -

    Try in D6

    =IF(AND($B6<>"",$B7=""),COUNT($B$6:$B6)-SUM($D$5:$D5),"")

    Drag/Fill Down

    [EDIT]

    This seems, to me at least, to better answer your problem.
    Using RANK() as a condition could be a bit difficult or perhaps just misleading.
    What would happen if the data-set has more than one value ranked first?
    Last edited by Marcol; 12-19-2010 at 10:44 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Array formulae/macro? Counting datasets -

    Try this
    Sub StuffToDo()
    
        Dim Rws As Long, Rng As Range, c As Range
        Dim Rnk As Range, y As Range, Srk As Range
    
        Rws = Cells(Rows.Count, "B").End(xlUp).Row
    
        Set Rng = Range(Cells(1, 2), Cells(Rws, 2))
    
        For Each c In Rng.Cells
    
            On Error Resume Next
    
            If c = "Data" Or c = "MS" Then
    
                Set y = Range(c.Offset(1, 0), c.End(xlDown))
    
                Set Rnk = Range(c.Offset(1, 1), c.Offset(1, 1).End(xlDown))
    
                For Each Srk In Rnk.Cells
    
                    If Srk.Offset(0, -1) <> "" Then
    
                        Srk = WorksheetFunction.Rank(Srk.Offset(0, -1), y)
    
                    End If
    
                Next Srk
    
            End If
    
        Next c
    
    End Sub

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Array formulae/macro? Counting datasets -

    Here's a formula approach, I perhaps missed that you also needed the ranking of each set.

    In Column A (Helper Column)
    In A6
    =IF(B6="","",IF(ISTEXT(B5),ROW(),A5))
    Drag/Fill Down

    In C6
    =IF(A6="","",RANK(INDIRECT("$B"&ROW()),INDIRECT("$B$"&A6&":$B$"&COUNTIF(A:A,A6)+A6-1),0))
    Drag/Fill Down

    In E6
    =IF(C6=1,COUNTIF(A:A,A6),"")
    Drag/Fill Down


    I have left my original suggestion in Column D for reference only, it isn't needed with the other formulae.

    This assumes that each of your data sets has a text header in Column B

    Hope this helps
    Attached Files Attached Files

+ 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