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

[µo°Ý] ¹Bºâ°ÝÃD

¦^´_ 1# jackyliu
³oµ{¦¡½X¬O¨Ì¾Ú,ªþÀÉ[TEST]ªº¼Ï¯Ã¤ÀªRªíªº²{¦³µ²ºc¦Ó¼gªº
  1. Sub Ex()
  2.     Dim D_1, D_2, R As Range, M As Integer
  3.     With Sheets("TEST").PivotTables(1)                           '¤u§@ªíªº¹ô¤@­Ó,¼Ï¯Ã¤ÀªRªí.
  4.         .Parent.Cells.Interior.ColorIndex = xlNone
  5.         With .ColumnRange
  6.             .Cells(1, .Columns.Count + 1).EntireColumn.Clear    '¼Ï¯Ã¤ÀªRªíªºÄæ¦ìªº³Ì¥kÃ䪺¤U¤@Äæ: ¾ãÄæ ¥þ³¡²M°£
  7.         End With
  8.         Application.DisplayAlerts = False
  9.         .SourceData = Sheets("RAW").Range("A1").CurrentRegion.Address(, , xlR1C1, 1)
  10.         '§ó·s¸ê®Æ®wªº¦ì¸m   CurrentRegion¤£·|¥]§t¦³ªÅ¥Õªº¸ê®Æ
  11.         '­ì¥ý¸ê®Æ®wªº¦ì¸m=> A:D ªº¾ãÄæ¥]§t¦³ªÅ¥Õªº¸ê®Æ
  12.         Application.DisplayAlerts = True
  13.         .PivotCache.Refresh
  14.         With .ColumnRange                                           '¼Ï¯Ã¤ÀªRªíªºÄæ¦ì
  15.             M = .Cells(1, .Columns.Count + 1).Column                '¼Ï¯Ã¤ÀªRªíªºÄæ¦ìªº³Ì¥kÃ䪺¤U¤@Äæ
  16.             D_1 = CDate(Application.Large(.Rows(2), 1))             '³Ì¤jªº¤é´Á
  17.             D_2 = CDate(Application.Large(.Rows(2), 2))             '¦¸¤@¤éªº¤é´Á
  18.             D_1 = .Rows(2).Find(D_1, LookIn:=xlValues).Column       '³Ì¤j¤é´Áªºøó¸¹
  19.             D_2 = .Rows(2).Find(D_2).Column                         '¦¸¤@¤éªºøó¸¹
  20.         End With
  21.         For Each R In .RowRange.Columns(1).Cells                    '¼Ï¯Ã¤ÀªRªíªº¦Cªº²Ä1Äæ
  22.             If InStr(R, "¦X­p") Then
  23.                 R.Resize(, .RowRange.Columns.Count + .ColumnRange.Columns.Count).Interior.Color = vbYellow
  24.                 With .Parent                                        '¼Ï¯Ã¤ÀªRªíªº¤÷¼h :¤u§@ªí
  25.                 .Cells(R.Row, M) = .Cells(R.Row, D_1) - .Cells(R.Row, D_2)
  26.                 End With
  27.             End If
  28.         Next
  29.     End With
  30. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 3# jackyliu
  1. Sub Ex()
  2.     Dim D_1, D_2, R As Range, M As Integer
  3.     With Sheets("TEST").PivotTables(1)                           '¤u§@ªíªº¹ô¤@­Ó,¼Ï¯Ã¤ÀªRªí.
  4.         .Parent.Cells.Interior.ColorIndex = xlNone
  5.         With .ColumnRange
  6.             .Cells(1, .Columns.Count + 1).EntireColumn.Clear    '¼Ï¯Ã¤ÀªRªíªºÄæ¦ìªº³Ì¥kÃ䪺¤U¤@Äæ: ¾ãÄæ ¥þ³¡²M°£
  7.         End With
  8.         Application.DisplayAlerts = False
  9.         .SourceData = Sheets("RAW").Range("A1").CurrentRegion.Address(, , xlR1C1, 1)
  10.         '§ó·s¸ê®Æ®wªº¦ì¸m   CurrentRegion¤£·|¥]§t¦³ªÅ¥Õªº¸ê®Æ
  11.         '­ì¥ý¸ê®Æ®wªº¦ì¸m=> A:D ªº¾ãÄæ¥]§t¦³ªÅ¥Õªº¸ê®Æ
  12.         Application.DisplayAlerts = True
  13.         .PivotCache.Refresh
  14.         With .ColumnRange                                           '¼Ï¯Ã¤ÀªRªíªºÄæ¦ì
  15.             M = .Cells(1, .Columns.Count + 1).Column                '¼Ï¯Ã¤ÀªRªíªºÄæ¦ìªº³Ì¥kÃ䪺¤U¤@Äæ
  16.             D_1 = CDate(Application.Large(.Rows(2), 1))             '³Ì¤jªº¤é´Á
  17.             D_2 = CDate(Application.Large(.Rows(2), 2))             '¦¸¤@¤éªº¤é´Á
  18.             D_1 = .Rows(2).Find(D_1, LookIn:=xlValues).Column       '³Ì¤j¤é´Áªºøó¸¹
  19.             D_2 = .Rows(2).Find(D_2).Column                         '¦¸¤@¤éªºøó¸¹
  20.         End With
  21.         Set R = .RowRange.Columns(1).Cells(2)
  22.         Do While Not Intersect(R, .RowRange.Columns(1)) Is Nothing
  23.             If InStr(R, "¦X­p") Then
  24.                 R.Resize(, .RowRange.Columns.Count + .ColumnRange.Columns.Count).Interior.Color = vbYellow
  25.             End If
  26.             With .Parent                                        '¼Ï¯Ã¤ÀªRªíªº¤÷¼h :¤u§@ªí
  27.                 .Cells(R.Row, M) = .Cells(R.Row, D_1) - .Cells(R.Row, D_2)
  28.             End With
  29.             Set R = R.Offset(1)
  30.         Loop
  31.     End With
  32. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 5# jackyliu
³o¦³¿ìªk°µ¨ì¥Î ´£¨Ñ¿ï¾Ü¤é´Á°Ï¶¡ ¶Ü?
¬O¥i¥Hªº,¦ý§AÀ³¸Ó¬O¦h»{ÃÑVBAªº¨ç¼Æ,ª«¥óªºÄÝ©Ê,¤èªk.½m²ß¦Û¤v¨Ó¼g,¤~¦³¦¨´N·Pªº.
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD