- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¦^´_ 4# dou10801
ÁÂÁ½׾Â,ÁÂÁ«e½ú¤@°_¾Ç²ß
«á¾ÇÂǦ¹©«½Æ²ß×q,¤è®×¤ß±o¦p¤U,½Ð«e½ú°Ñ¦Ò
Option Explicit
Sub TEST()
Application.DisplayAlerts = False
Dim Brr, i&, xR As Range, Z, T$, j%, Find As Range
'¡ô«Å§iÅܼÆ:&¬Oªø¾ã¼Æ,$¬O¦r¦êÅܼÆ,%¬Oµu¾ã¼Æ,¨S¦³«ü©wªº¬O³q¥Î«¬ÅܼÆ
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZÅܼƬO ¦r¨å
Brr = Range([¾Ç¥Í¦W¥U!F1], [¾Ç¥Í¦W¥U!A65536].End(3))
'¡ô¥OBrrÅܼƬO ¥H¤u§@ªíÀx¦s®æȱa¤Jªº¤Gºû°}¦C
For j = 4 To 6
'¡ô³]¶¶°j°éj±q4 ¨ì6
T = Trim(Brr(1, j))
'¡ô¥OTÅܼƬO1¦Cj°j°éÄæBrr°}¦CÈ
If T = "" Then GoTo j01
'¡ô¦pªGTÅܼƬOªÅ¦r¤¸´N¸õ¨ì¼Ð¥Ü j01¦ì¸mÄ~Äò°õ¦æ
Set Find = [¼Òª©®Mªí!B5:X7].Find(T, Lookat:=xlWhole)
'¡ô¥O¥HTÅܼƷj´M½d³òÀx¦s®æÈ¥þ¦PªºÀx¦s®æ
If Find Is Nothing Then MsgBox "§ä¤£¨ì " & T & " ¶µ¥Ø": Exit Sub
'¡ô¦pªG§ä¤£¨ì!´N¸õ¥X´£¥Ü,µ²§ôµ{¦¡°õ¦æ
Z(T) = j: Set Z(Find & "/ad") = Find(, 6).Resize(, 2)
'¡ô¥OZ¦r¨å°O¿ý"¾Ç¥Í¦W¥U"ªíÄ渹,¥O¥HZ¦r¨å°O¿ý"¼Òª©®Mªí"ªíÀx¦s®æ
j01: Next
With Sheets("µ²ªG")
.Activate: .UsedRange.EntireRow.Delete: Set xR = .[A1]
'¡ô¥O¿E¬¡µ²ªGªí,¥O¸ê®Æ¾ã¦C§R°£,¥OxRÅܼƬO(ª«¥ó)Àx¦s®æ[A1]
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é±q2¨ì Brr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
[¼Òª©®Mªí!D3] = Brr(i, 1): [¼Òª©®Mªí!K3] = Brr(i, 2): [¼Òª©®Mªí!P3] = Brr(i, 3)
'¡ô¥O°j°é¦C¯Z¯Å/®y¸¹/©m¦W ¦UÄæ±a¤Jµ²ªGªí
For j = 1 To Z.Count - 1 Step 2: Z.Items()(j).Value = Brr(i, Z.Items()(j - 1)): Next
'¡ô³]¶¶°j°é±N ®ÑÄy¶O/»²¾É¶O/¨ä¥L ¦UÄæ±a¤Jµ²ªGªí
[¼Òª©®Mªí!1:15].Copy xR: Set xR = xR(16)
[¼Òª©®Mªí!1:15].Copy xR: xR(5, 28) = "²Ä¤GÁp¦Û¯d": Set xR = xR(16)
[¼Òª©®Mªí!1:14].Copy xR: xR(5, 28) = "²Ä¤TÁp¦¬¾Ú": Set xR = xR(15)
'¡ô¥O½Æ»s "¼Òª©®Mªí"ªí¸ê®Æ¦C¨ìµ²ªGªí«ü©wÀx¦s®æ
xR.PageBreak = xlPageBreakManual
'¡ô¥O³]©w ¤â°Ê¤À¶
Next
.UsedRange.Interior.ColorIndex = xlNone
'¡ô¥Oµ²ªGªíÀx¦s®æ©³¦â¬°µL¦â
.Names.Add Name:="PrintArea", RefersTo:=Range(.[A1], xR(0, 28))
'¡ô¥O²K¥[ ¦WºÙ,³]©wÀx¦s®æ½d³ò
.PageSetup.PrintArea = "PrintArea"
'¡ô³]©w¦C¦L½d³ò
MsgBox "°õ¦æ§¹¦¨"
End With
End Sub |
|