ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ListBox»P±Æ§Ç¥[Á`°ÝÃD

¦^´_ 1# starbox520
¼Ï¯Ã¤ÀªRªí²Ó³¡½Õ¾ã«á¤]¯à¹F¦¨
  1. Sub test()
  2.     Dim rngData As Range: Set rngData = Sheets("¤u§@ªí1").Range("A1:E33")
  3.     Dim arKeyFields: arKeyFields = Array("CR", "LN", "PG", "BE")
  4.     Dim sumField: sumField = "QQ"

  5.     Dim pvt As PivotTable, i, x
  6.     With Sheets.Add
  7.         Set pvt = ActiveWorkbook.PivotCaches.Create( _
  8.                 SourceType:=xlDatabase, _
  9.                 SourceData:=rngData, _
  10.                 Version:=xlPivotTableVersion14 _
  11.             ).CreatePivotTable(TableDestination:=.[A1])
  12.     End With
  13.     With pvt
  14.         .InGridDropZones = False
  15.         .ShowDrillIndicators = False
  16.         .DisplayFieldCaptions = True
  17.         .RowGrand = False
  18.         .ColumnGrand = False
  19.         .RowAxisLayout xlTabularRow
  20.         i = 1
  21.         For Each x In arKeyFields
  22.             .PivotFields(x).Orientation = xlRowField
  23.             .PivotFields(x).RepeatLabels = True
  24.             .PivotFields(x).Subtotals(1) = False
  25.             .PivotFields(x).Position = i
  26.         Next
  27.         .AddDataField .PivotFields(sumField), "¥[Á` - " & sumField, xlSum
  28.     End With
  29. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 6# starbox520
4# º|¤F i=i+1

§A¦A§ï²Ä¤@¦æªº¸ê®Æ½d³ò´N¦n¤F
Set rngData = Sheets("¤u§@ªí2").Range("A1:G33")
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¥ÌÄ@°µ¡BÅw³ß¨ü¡C
ªð¦^¦Cªí ¤W¤@¥DÃD