- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-10-2 09:03 ½s¿è
¦^´_ 10# Changbanana
¤£¥Î¦r¨åª«¥ó ªº¼gªk- Option Explicit
- Sub Ex()
- Dim r As Integer, Ar(), i As Integer
- '*******«e¸m§@·~
- With Range("A:A").CurrentRegion
- 'CurrentRegion :¥Ø«e°Ï°ì,¬O«ü¥H¥ô·NªÅ¥Õ¦C¤ÎªÅ¥ÕÄ檺²Õ¦X¬°Ãä¬Éªº½d³ò
- .Sort key1:=.Cells(1), order1:=xlAscending, key2:=.Cells(4), order1:=xlAscending, header:=xlYes '±Æ§Ç
- .Columns(1).AdvancedFilter ACTION:=xlFilterCopy, COPYTORANGE:=Cells(1, Columns.Count), Unique:=True
- '¶i¶¥¿z¿ï:¶i¶¥¤£«½Æ¸ê®Æ,¦Ü©ó¤u§@ªíªº³Ì¥kÃ䪺Äæ¦ì
- End With
- '************************
- r = Cells(Rows.Count, Columns.Count).End(xlUp).Row 'pºâ ¿z¿ï ¸ê®Æ¼Æ («È¤á½s¸¹)
- ReDim Ar(1 To r) '«¸m°}¦C¤j¤p¬° («È¤á½s¸¹)Ó¼Æ
- Ar(1) = Application.Transpose(Application.Transpose(Range("A1").Resize(, 6))) 'ªíÀY ¸m¤J°}¦C
- For i = 2 To r '°j°é («È¤á½s¸¹)
- With Range("A:A")
- .Replace Cells(i, Columns.Count), "=1/0" '±N («È¤á½s¸¹) §ï¬° ¿ù»~È
- With .SpecialCells(xlCellTypeFormulas, xlErrors).Resize(, 6) '¿ù»~Ȫº½d³ò
- .Columns(1) = Cells(i, Columns.Count) ' '±N ¿ù»~È §ï¦^ ì «È¤á½s¸¹
- Ar(i) = Array(.Cells(1).Value, .Cells(2).Value, .Cells(3).Value, .Cells(4).Value, Application.Sum(.Columns(5)), .Cells(.Rows.Count, 6).Value) 'Application.Sum(.Columns(5)) ¥[Á`(«È¤á½s¸¹)ªºCASH
- End With
- End With
- Next
- With Range("I1")
- .Resize(r, 6).EntireColumn = "" '²M°£Â¦³¸ê®Æ
- .Resize(r, 6) = Application.Transpose(Application.Transpose(Ar)) '½d³ò¤º¾É¤JÂà¸m2¦¸ªº°}¦C
- End With
- Cells(1, Columns.Count).EntireColumn = "" '²M°£Â¦³¸ê®Æ
- End Sub
- '*********************************************************************
- Sub Ex1()
- Dim Rng As Range, Ar(), i As Integer
- '*******«e¸m§@·~
- With Range("A:A").CurrentRegion
- 'CurrentRegion :¥Ø«e°Ï°ì,¬O«ü¥H¥ô·NªÅ¥Õ¦C¤ÎªÅ¥ÕÄ檺²Õ¦X¬°Ãä¬Éªº½d³ò
- .Sort key1:=.Cells(1), order1:=xlAscending, key2:=.Cells(4), order1:=xlAscending, header:=xlYes '±Æ§Ç
- End With
- '************************
- i = 1
- ReDim Ar(1 To i) '«¸m°}¦C¤j¤p¬° («È¤á½s¸¹)Ó¼Æ
- Ar(1) = Application.Transpose(Application.Transpose(Range("A1").Resize(, 6))) 'ªíÀY ¸m¤J°}¦C
- Set Rng = Range("A2")
- Do While Rng <> "" '«È¤á½s¸¹ <> ""
- i = i + 1
- ReDim Preserve Ar(1 To i)
- With Rng
- Ar(i) = Array(.Cells(1).Value, .Cells(1, 2).Value, .Cells(1, 3).Value, .Cells(1, 4).Value, .Cells(1, 5).Value, .Cells(.Rows.Count, 6).Value)
- End With
- Do While Rng = Rng.Offset(1) '¦P¤@ («È¤á½s¸¹)
- Ar(i)(4) = Ar(i)(4) + Rng.Cells(1, 5) '¥[Á`¦P¤@ («È¤á½s¸¹)ªºCASH
- Ar(i)(5) = Rng.Cells(2, 6)
- Set Rng = Rng.Offset(1) '¤U¤@ӫȤá½s¸¹
- Loop
- Set Rng = Rng.Offset(1) '¤U¤@ӫȤá½s¸¹
- Loop
- With Range("I1")
- .Resize(, 6).EntireColumn = "" '²M°£Â¦³¸ê®Æ
- .Resize(i, 6) = Application.Transpose(Application.Transpose(Ar)) '½d³ò¤º¾É¤JÂà¸m2¦¸ªº°}¦C
- End With
- End Sub
½Æ»s¥N½X |
|