![](/img/trans.png)
[英]Count of Rows Based on Their Most Recent Value in Excel PowerPivot Using DAX
[英]Excel PowerPivot - Working with grouped rows
我正在处理一个非常大的excel工作表,该工作表基本上是用户列表以及他们使用的应用程序。 现在的问题是,有超过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提取此信息?
一种方法是:
在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.