繁体   English   中英

Excel PowerPivot-使用分组的行

[英]Excel PowerPivot - Working with grouped rows

我正在处理一个非常大的ex​​cel工作表,该工作表基本上是用户列表以及他们使用的应用程序。 现在的问题是,有超过60000个用户,每个用户至少有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. 在新工作簿中创建电子表格的副本。
  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 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM