データの並べ替えが許可されていると仮定すると、これは正常に機能します。 30,000を超えるデータ行でテストされ、0.1秒未満で正常に完了しました。わかりやすくするために、コメントコード:
Sub ParseJobData()
Dim ws As Worksheet
Dim rData As Range
Dim aData As Variant
Dim aResults() As Variant
Dim sTemp As String
Dim ResultIndex As Long
Dim i As Long
Set ws = ActiveWorkbook.ActiveSheet 'Make sure this is the correct sheet
Set rData = ws.Range("F1").CurrentRegion 'Make sure this is the correct range
rData.Sort rData.Columns(1), xlAscending, Header:=xlYes 'Sort data
aData = rData.Value 'Load data into array
ReDim aResults(1 To 65000, 1 To 3) 'Save data in Results array
'Starting at 2 in order to skip header row
For i = 2 To UBound(aData, 1)
'Check if this is a new name
'Data is sorted, so new name only happens when previous name is completed
If aData(i, 1) <> sTemp Then
'New name, increase ResultIndex, store the name
ResultIndex = ResultIndex + 1
sTemp = aData(i, 1)
aResults(ResultIndex, 1) = sTemp
End If
'Column 2 is a count of jobs, increase it by 1
aResults(ResultIndex, 2) = aResults(ResultIndex, 2) + 1
'Column 3 is a sum of payment, increase by the amount
aResults(ResultIndex, 3) = aResults(ResultIndex, 3) + aData(i, 3)
Next i
'You have now built your array of unique values with a count and sum
'Do what you want with the array here
'This simply outputs it
ws.Range("J1").Resize(ResultIndex, UBound(aResults, 2)).Value = aResults
End Sub
その後、既にピボットテーブル場合はそれを –
を行うには、このリストとworksheetfunction.sumifと.countifを使用dupesをチェックし、列Fからリストをコンパイルするために辞書を使用し、.Exists必要な結果が得られます。なぜVBAでこれを行う必要がありますか? – tigeravatar
@tigeravatar私の最終目標は、データで何か他のことをしているので、結果のピボットテーブルを作成しないことです。私はちょうど必要なデータを表示するピボットテーブルを作成しました – BDillan