Results 1 to 5 of 5

Thread: Managing Filtered Items

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Arrow Managing Filtered Items

    Hi
    how can i apply any formula on items which are resulted because of a filter ( since filtered items are in random order )
    also take a look at attachment
    i need a lil vb program which could scan worksheet "Results" and column "G" ( with header "Node") and look for same text like .. for example start with "MDLH1194" it should apply the formula ( i have applied that forumula ) in front of this text ( see H2 , H15 and H65 ) to calculate duration wherever it finds "MDLH1194" text in G column .. after that it should sum up those durations as i have did ( see I2 ) and also print output like i have printed in worksheet "Analysis" (calculate minutes aswell in E2) .. ignore H233 in "Results"
    and then jump over to next Node and repeat till it is done with all distinct nodes
    i hope it will be a piece of cake for u gurus
    waiting
    Regards
    Attached Files Attached Files

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Managing Filtered Items

    Why don't you just fill the formula in all the Duration formulas in Col H and then create a pivot table, grouping by Node?
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Managing Filtered Items

    Or, if you don't like pivot tables, you could use a SumIF formula.

    Here's your sample workbook with examples of both.
    Attached Files Attached Files
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Location
    Lahore
    Posts
    214

    Re: Managing Filtered Items

    its nice effort and i love to rate ur post for that .. but u know all i want is to get rid of this "click" and "select" thingy .. when u have almost 60,000 lines for each block and u have to repeat same procedure for almost 30 blocks .. that takes a lot of energy ... a lil vb program generating total durations for each node is everything i need
    besides if u could guide me on this "Pivot table and chart" option .. that how can i generate the output as u have generated from raw data ( step by step) .. it is nice since it also creates a chart for me ( i can impress my boss with that )

  5. #5
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Managing Filtered Items

    Try this.
    Note: this assumes that you have included the calculation of Duration in column H before you generate the report.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type ReportLine
    4.     sBSC As String
    5.     sEvent As String
    6.     sNode As String
    7.     dtTotTime As Date
    8. End Type
    9.  
    10. Sub DK_report()
    11. Dim lLastRow As Long
    12. Dim rngData As Range
    13. Dim vaLineData() As ReportLine
    14. Dim lRowNum As Long
    15. Dim bProcessed As Boolean
    16. Dim lLineId As Long
    17. Dim lRecordCount As Long
    18. Dim wksReport As Worksheet
    19. Dim rngOutput As Range
    20.    
    21.     'Set a reference to the source data
    22.     With ThisWorkbook.Worksheets("Results")
    23.         lLastRow = .Range("A65536").End(xlUp).Row
    24.         Set rngData = .Range(.Cells(2, 1), .Cells(lLastRow, 8))
    25.     End With
    26.    
    27.     ReDim vaLineData(0)
    28.    
    29.     With rngData
    30.         For lRowNum = 1 To .Rows.Count
    31.            
    32.             'Assume we have not yet processed this node
    33.             bProcessed = False
    34.            
    35.             'Loop through the processed nodes..
    36.             For lLineId = LBound(vaLineData) To UBound(vaLineData)
    37.                
    38.                 '..Looking for a match to the current row
    39.                 If vaLineData(lLineId).sNode = .Cells(lRowNum, 7) Then
    40.                    
    41.                     '..If a match is found
    42.                     'record that and stop looping
    43.                     bProcessed = True
    44.                     Exit For
    45.                    
    46.                 End If
    47.                
    48.             Next lLineId
    49.            
    50.             'For New nodes, record the required values
    51.             If Not bProcessed Then
    52.                 vaLineData(UBound(vaLineData)).sBSC = .Cells(lRowNum, 1)
    53.                 vaLineData(UBound(vaLineData)).sEvent = .Cells(lRowNum, 2)
    54.                 vaLineData(UBound(vaLineData)).sNode = .Cells(lRowNum, 7)
    55.                 vaLineData(UBound(vaLineData)).dtTotTime = Application.WorksheetFunction.SumIf(.Columns(7), .Cells(lRowNum, 7), .Columns(8))
    56.                
    57.                 'And increase the size of the array
    58.                 ReDim Preserve vaLineData(UBound(vaLineData) + 1)
    59.             End If
    60.         Next lRowNum
    61.     End With
    62.    
    63.     'Remove the unused record from the array
    64.     ReDim Preserve vaLineData(UBound(vaLineData) - 1)
    65.    
    66.     'How many line in the report?
    67.     lRecordCount = UBound(vaLineData) - LBound(vaLineData) + 1
    68.    
    69.     'Add a new sheet
    70.     Set wksReport = ThisWorkbook.Worksheets.Add
    71.    
    72.     Application.ScreenUpdating = False
    73.    
    74.     With wksReport
    75.         .Move after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
    76.         .Name = "Report- " & Format(Now(), "yy-mm-dd hh,mm,ss")
    77.         .Range("A1").Value = "BCS"
    78.         .Range("B1").Value = "Event Type"
    79.         .Range("C1").Value = "Node"
    80.         .Range("D1").Value = "Total"
    81.         .Range("E1").Value = "Total (Minutes)"
    82.         .Range("D:D").NumberFormat = "hh:mm:ss"
    83.        
    84.         'Loop through the array, writing the value to the report
    85.         For lRowNum = 2 To lRecordCount + 1
    86.             .Cells(lRowNum, 1) = vaLineData(lRowNum - 2).sBSC
    87.             .Cells(lRowNum, 2) = vaLineData(lRowNum - 2).sEvent
    88.             .Cells(lRowNum, 3) = vaLineData(lRowNum - 2).sNode
    89.             .Cells(lRowNum, 4) = vaLineData(lRowNum - 2).dtTotTime
    90.             .Cells(lRowNum, 5) = CInt(vaLineData(lRowNum - 2).dtTotTime * 60 * 24)
    91.         Next lRowNum
    92.        
    93.         .Columns("A:E").AutoFit
    94.     End With
    95.    
    96.     Application.ScreenUpdating = True
    97.     Set wksReport = Nothing
    98. End Sub
    Attached Files Attached Files
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width