- ©«¤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
|
¦^´_ 1# 520iopiop
ªþ¥ó¶K¤£¤W½×¾Â,¥Î¨p¤HªÅ¶¡Â\©ñ!! ±NÀɮשñ¦bÀ£ÁYÀÉ¥i¤W¶Ç
¸Õ¸Õ¬Ý- Option Explicit
- Sub Ex()
- Dim Sh(1 To 2) As Worksheet, Rng(1 To 3) As Range, CRng(1 To 2) As Range
- Dim i As Integer, R As Integer, C As Integer
- Set Sh(1) = Sheets("Sheet1") '¸ê®Æªí
- Set Sh(2) = Sheets("Sheet2") '§e²{ªí
- Set Rng(1) = Sh(1).Range("i3:j3") '½Òµ{°_¤é~½Òµ{¨´¤é
- Set Rng(2) = Sh(2).Range("c4") '±Æµ{¶}©l¤é´Á
-
- Set CRng(1) = Sh(1).Range("M2:S2") '¤W½Ò¬P´Á
- Set CRng(2) = Sh(2).Range("b5", Sh(2).Range("b5").End(xlDown)) '¤W½Ò®É¶¡
-
- Rng(2).Offset(1).Resize(CRng(2).Rows.Count, 7) = "" '²M°£§e²{ªí
-
- Do While Rng(1).Cells(1) <> "" '½Òµ{°_¤é<>""
- i = 0 '±Æµ{¶}©l¤é´ÁªºÄæ¦ì
- Do While Rng(2).Offset(, i) >= Rng(1).Cells(1) And Rng(2).Offset(, i) <= Rng(1).Cells(2)
- '°j°éªº±ø¥ó:§e²{ªíªº¤é´Á¬O[½Òµ{°_¤é~½Òµ{¨´¤é]ªº´Á¶¡
- C = CRng(1).Cells(Application.Match(Format(Rng(2).Offset(, i), "AAAA"), CRng(1), 0)).Column
- 'C = ¸ê®Æªíªº¤W½Ò¬P´Á¤¤·j´M,±Æµ{¤é´Áªº¬P´ÁÄæ¼Æ
- Set Rng(3) = Sh(1).Cells(Rng(1).Row, C) '¸ê®Æªíªº¤W½Òªº®É¶¡°Ï¬q
- If Rng(3) <> "" Then
- R = Application.Match(Rng(3), CRng(2), 1)
- 'R=¦C¼Æ:§e²{ªíªº¤W½Òªº®É¶¡¤¤©Ò¹ïÀ³ªº,¸ê®Æªíªº¤W½Òªº®É¶¡
- Rng(2).Offset(R, i) = IIf(Rng(2).Offset(R, i) = "", Sh(1).Cells(Rng(1).Row, "B"), Rng(2).Offset(R, i) & vbLf & Sh(1).Cells(Rng(1).Row, "B"))
- '±Æµ{¶}©l¤é´Á(R¦C, iÄæ)
- 'Sh(1).Cells(Rng(1).Row, "B") =>¸ê®Æªíªº¾Çû½s¸¹
- End If
- i = i + 1 'Rng(2).Offset(, i)->±Æµ{¶}©l¤é´ÁªºÄæ¦ì,¦V¥k²¾°Ê¤@Äæ
- Loop
- Set Rng(1) = Rng(1).Offset(1) '½Òµ{°_¤é,¦V¤U²¾°Ê¤@¦C
- Loop
- CRng(2).EntireRow.AutoFit
- End Sub
½Æ»s¥N½X |
|