Sub tyuumosuu() ‘件数カウント 注文番号重複除外
Dim i As Long
Dim j As Long
Dim maxRow As Long
Dim strMat, lngNum
Dim sh1 As Worksheet
Set sh1 = Worksheets(“未出荷レポート”)
Dim sh2 As Worksheet
Set sh2 = Worksheets(“出荷表”)
Dim dic
Set dic = CreateObject(“Scripting.Dictionary”)
lrwo = sh1.Cells(Rows.Count, 1).End(xlUp).Row ‘最終行
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual ‘自動計算停止(手動計算)
j = 2 ‘リスト書き出し開始行
maxRow = sh1.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To maxRow
strMat = sh1.Cells(i, 1).Value
If dic.Exists(strMat) Then’重複してたら何もしない
Else
dic.add (sh1.Cells(i, 1).Value), j’重複してなければデータ追加
j = j + 1
End If
Next i
sh2.Cells(3, 3).Value = “注文件数 ” & j – 2 & “件 出荷個数”
Application.Calculation = xlCalculationAutomatic '自動計算開始
Application.ScreenUpdating = True '画面描画再開
End Sub