fork download
  1. Sub 抽出()
  2. '品名呼び出し
  3. Dim i
  4. For i = 3 To 22
  5. Call 指定品名抽出(Worksheets("Sheet2").Cells(i, "B").Value, i)
  6. Next i
  7. End Sub
  8.  
  9.  
  10. Sub 指定品名抽出(ByVal hinmei As String, ByVal wrow As Long)
  11. 'オートフィルターで抽出
  12. Dim Count As Long
  13. With Worksheets("Sheet3")
  14. '抽出条件1
  15. .Range("B4").AutoFilter 6, Array("五個入り", "10個入り", "ケース ", "1個"), xlFilterValues
  16. '抽出条件2
  17. .Range("B4").AutoFilter 2, hinmei
  18. Count = WorksheetFunction.Subtotal(3, .Range("B4").CurrentRegion.Columns(1))
  19. End With
  20.  
  21. '処理月へ転記
  22. Dim c As Long
  23. With Worksheets("Sheet2")
  24. For c = 3 To 14 '4月~3月の範囲
  25. If .Cells(2, c).Value = Worksheets("Sheet1").Range("A2").Value Then
  26. .Cells(wrow, c) = Count - 1
  27. Exit For
  28. End If
  29. Next c '該当月の指定
  30. End With
  31. End Sub
  32.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty