Excel PowerPivot – 使用分组行

我正在研究一个非常大的Excel表单,它基本上是一个用户列表以及他们使用的应用程序。 现在的问题是,有超过6万用户,每个应用程序至less有10个应用程序。 所以它是一个巨大的表。 每周2-3次我需要提取某些特定用户使用的应用程序的详细信息。 有时候是2个用户。 有时候有10个用户。 但由于电子表格的大小,这项活动需要我永远(1-2小时)。

现在,工作表的结构如下。

StaffId Name DeviceNo Location ApplicationCount+ AppID Application Name 12345 John Doe DSK-982333 Mespil Road 24+ 123 Adobe Acrobat 234 WinZip 345 Google Chrome 

这里的+号表示分组行。

反正我有使用PowerPivots来提取这些信息吗?

一种方法是:

  1. 在新的工作簿中创build电子表格的副本。
  2. 在工作簿中添加另一个工作表,其中包含要筛选的人员的StaffId(在列“A”中)。
  3. 在VBA编辑器中,插入一个新模块并添加以下代码:

     Sub FilterForUsersOfInterest() Dim BigSheet As Worksheet Dim ListSheet As Worksheet Dim lastCell As Range Set BigSheet = ActiveWorkbook.Sheets("ListOfApplications") 'Change the sheet name here to match your main data tab Set ListSheet = ActiveWorkbook.Sheets("ListOfUsers") 'Change the sheet name here to match your sheet with the users of interest this time round 'Find the last used row on the worksheet Set lastCell = BigSheet.UsedRange.Item(BigSheet.UsedRange.Cells.Count) 'Copy the values for Staff Id down all the rows For iRow = 2 To lastCell.Row If BigSheet.Range("A" & iRow) = "" Then BigSheet.Range("A" & iRow) = BigSheet.Range("A" & iRow - 1) End If Next iRow 'Now work your way back up the rows, deleting any rows where the StaffId is not found in the current list of "users of interest" For iRow = lastCell.Row To 2 If Application.WorksheetFunction.CountIf(ListSheet.Range("A:A"), BigSheet.Range("A" & iRow)) = 0 Then BigSheet.Range("A" & iRow).EntireRow.Delete End If Next iRow End Sub