½Ð°Ý¦p¦ó¥ÎVBA.¦Û°Ê¦X¨ÖÀx¦s®æ"¸ó¦C¸m¤¤"
- ©«¤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
        
|
¦^´_ 4# joey3277
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim Rng(1 To 3) As Range, A As Range, C As Range, R As Integer
- On Error Resume Next '¤£²z·|µ{§Ç¤Wªº¿ù»~,Ä~Äò°õ¦æµ{¦¡
- Set Rng(1) = Application.InputBox("¿ï¨úÀx¦s®æ(¥i¿ï¦h«½d³ò)", Type:=8) '¦p¨S¦³¿ï¨úÀx¦s®æ:µ{§Ç¤Wªº¿ù»~
- If Err <> 0 Then Exit Sub 'µ{§Ç¤W¦³¿ù»~
- On Error GoTo 0 '¤£³B¸Ìµ{§Ç¤Wªº¿ù»~
- For Each A In Rng(1).Areas 'ª«¥ó¶°¦X: Areas (¦h«½d³ò)
- For Each C In A.Columns 'ª«¥ó¶°¦X: Columns(øó¦ì)
- Set Rng(2) = C.Cells(1) 'ª«¥ó:½d³òªº,²Ä1Ó,Àx¦s®æ¶}©l
- R = C.Cells(C.Cells.Count).Row '¼ÆÈ :ª«¥ó½d³ò³Ì«áªºÀx¦s®æ¦C¸¹
- Do
- Set Rng(3) = Rng(2).Offset(1) 'ª«¥ó Rng(3): Rng(2)ªº¤U¤@¦CÀx¦s®æ
- Do While Rng(3) = "" And Rng(3).Row <= R 'While(±ø¥ó¦¨¥ß,°õ¦æ°j°é):(ª«¥ó="" ¥B¶· ª«¥ó<>ª«¥ó½d³òªº³Ì«á¦C¸¹)
- Set Rng(3) = Rng(3).Offset(1) 'ª«¥ó Rng(3): Rng(3)ªº¤U¤@¦CÀx¦s®æ
- Loop
- Rng(1).Parent.Range(Rng(2), Rng(3).Offset(-1)).Merge 'Merge(¦X¨ÖÀx¦s®æ)
- Set Rng(2) = Rng(3) 'ª«¥ó Rng(2): ¦³¸ê®Æ¼ÆȪºÀx¦s®æ
- Loop Until Rng(3).Row > R 'Until(±ø¥ó¤£¦¨¥ß,°õ¦æ°j°é)
- Next
- Next
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|