- ©«¤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
|
¦^´_ 3# adam2010 - Option Explicit
- Sub Ex()
- Dim Rng(1 To 2) As Range, M As String, R As Integer
- With ActiveSheet
- Set Rng(1) = .Range("A2") 'ª«¥ó: A2Àx¦s®æ
- R = .[A1].End(xlToRight).Column '¼ÆÈ: A1©¹¥k¨ì³Ì«á¦³¼ÆȪºÄ渹
- Do
- If InStrRev(Rng(1), "X") <> Len(Rng(1)) And M = "" Then 'Àx¦s®æ¥kÃä²Ä¤@Ó¦r¦ê<>"X" ¥B M = ""
- M = Mid(Rng(1), 1, Len(Rng(1)) - 1) 'M = ¥h±¼Àx¦s®æ¥kÃä²Ä¤@Ó¦r¦êªº¦r¦ê
- Set Rng(2) = Rng(1) 'ª«¥ó Rng(2) :²Ä1 Ó¤lÀɦì¸m
- ElseIf InStrRev(Rng(1), "X") = Len(Rng(1)) Then '¬O¥ÀÀÉ
- Rng(1).Resize(1, R).Interior.Color = vbGreen '***¥[¤J©³¦â
- M = "" '¬O¥ÀÀÉ : M=""
- ElseIf M <> "" And M <> Mid(Rng(1), 1, Len(Rng(1)) - 1) Then 'Ū§¹¬Û¦Pªº¤lÀÉ
- Rng(1).EntireRow.Insert '¨Ï¥Î´¡¤J¤èªk,Rng(1)·|¤U²¾
- Set Rng(1) = Rng(1).Offset(-1) '¥ÀÀɪº¦ì¸m
- Set Rng(2) = Range(Rng(1).Offset(-1), Rng(2)) '©Ò¦³¤lÀɪº½d³ò
- With Rng(1)
- .Resize(1, R).Interior.Color = vbGreen '***¥[¤J©³¦â
- .Cells = M & "X"
- .Cells(1, "H").Resize(1, R - 8) = "=SUM(R[-1]C:R[-" & Rng(2).Rows.Count & "]C)"
- ' R - 8 : Høó¨ì A1©¹¥k¨ì³Ì«á¦³¼ÆȪºÄ渹 - 1øó
- .Cells(1, "H").Resize(1, R - 8) = .Cells(1, "H").Resize(1, R - 8).Value
- .Cells(1, R) = Application.Sum(.Cells(1, 8).Resize(1, R - 8))
- .Cells(1, "D") = Application.Sum(Rng(2).Range("D1:F" & Rng(2).Rows.Count))
- .Cells(1, "G") = .Cells(1, "D") - .Cells(1, R)
- End With
- M = ""
- End If
- Set Rng(1) = Rng(1).Offset(1) 'ª«¥ó Rng(1)²¾©¹¤U¤@¦C
- Loop Until Rng(1) = ""
- End With
- End Sub
½Æ»s¥N½X |
|