- ©«¤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
|
¦^´_ 23# Andy2483
½Æ²ß&¦AÀˬdקïµ{¦¡½Xµù¸Ñ¦p¤U:
Option Explicit
Sub TEST()
Dim Brr, Y, C&, i&, j&, R&, N&, Sh As Worksheet
'¡ô«Å§iÅܼÆ:(Brr, Y)¬O³q¥Î«¬,(C,i,j,R,N)¬Oªø¾ã¼Æ,(Sh)¬O¤u§@ªí
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY ¬O¦r¨å
Set Sh = ActiveSheet: N = 15
'¡ô¥OSh ¬O²{¥Î¤u§@ªí: ¥ON=15
Brr = Range(Sh.[A1], Sh.Cells(Sh.UsedRange.Rows.Count, "AM"))
'¡ô¥OBrr¬O¤Gºû°}¦C!ˤJ[A1]¨ì(AMÄæ/³Ì«á¦³¨Ï¥ÎªºÀx¦s®æ¨º¤@¦Cªº¦C¸¹Àx¦s®æ) È
For i = 1 To 39
'¡ô³]¶¶°j°é!i±q 1¨ì39
Y(i & "C") = Columns(i).ColumnWidth
'¡ô¥O°j°é¼Æ³s±µ"C"·íkey,item¬O°j°é¼ÆÄæ¦ìªºÄæ¼e
Y(i & "R") = Rows(i).Rows.RowHeight
'¡ô¥O°j°é¼Æ³s±µ"R"·íkey,item¬O°j°é¼Æ¦C¦ìªº¦C°ª
Next
For i = 16 To UBound(Brr)
'¡ô³]¥~¶¶°j°é!i±q 16¨ìBrr°}¦CÁa¦V³Ì¤j¦C¸¹¼Æ
If IsNumeric(Brr(i, 37)) And Brr(i, 37) <> "" Then
'¡ô¦pªGIsNumeric()¨ç¼Æ§PÂ_°j°é¦C²Ä37ÄæBrr°}¦CȬO¼Æ¦r,¥B¤£¬OªÅ¦r¤¸
N = N + 1
'¡ôN¼Æ¦rÅܼƲ֥[ 1
For j = 1 To 39
'¡ô³]¤º¶¶°j°é!j±q 1¨ì39
Brr(N, j) = Brr(i, j)
'¡ô¥ONÅܼƦC²Äj°j°éÄ檺Brr°}¦CȬO iÅܼƦC²Äj°j°éÄ檺Brr°}¦CÈ
Next
End If
Next
Set Y("ªíÀY") = Range(Sh.[A1], Sh.[AM16])
'¡ô¥O¥H "ªíÀY"¦r¦ê¬°key,item¬O²{¥Î¤u§@ªí[A1]¨ì[AM16]Àx¦s®æ¶°,ˤJY¦r¨å¸Ì
'¦b¶}¤@Ó·s¬¡¶Ã¯¤§«e§â¥Î±o¨ìªº¸ê®Æ¥Î¦r¨å»P°}¦C¸Ë°_¨Ó
'Y("ªíÀY")Àx¦s®æ¸Ì¦³¤½¦¡!
Workbooks.Add
'¡ô¶}¤@Ó·s¬¡¶Ã¯
Y("ªíÀY").Copy [A1]
'¡ô¥O¥H "ªíÀY"¦r¦ê¬dY¦r¨å,§âÀx¦s®æ¶°½Æ»s¨ì¦¹·s¬¡¶Ã¯[A1]
For i = 1 To 39
'¡ô³]¶¶°j°é!i±q 1¨ì39
Columns(i).ColumnWidth = Y(i & "C")
'¡ô¥Hi°j°é¼Æ³s±µ"C"ªº¦r¦ê¬dY¦r¨åªºitemÈ ¬°i°j°é¼ÆÄæÄæ¼e
Rows(i).Rows.RowHeight = Y(i & "R")
'¡ô¥Hi°j°é¼Æ³s±µ"R"ªº¦r¦ê¬dY¦r¨åªºitemÈ ¬°i°j°é¼Æ¦C¦C°ª
Next
Range([A16], [AM16]).ClearContents
'¡ô[A16]¨ì[AM16]Àx¦s®æ¤º®e²MªÅ
Range([A16], [AM16]).Borders.LineStyle = 1
'¡ô[A16]¨ì[AM16]Àx¦s®æ®æ½u¬O²Ó¹ê½u
[16:16].Copy Rows("17:" & N)
'¡ô²Ä16¦C½Æ»s¨ì 17¦Ü NÅܼƦC
[A1].Resize(N, 39) = Brr
'¡ô¥O[A1]ÂX®i¦V¤UNÅܼƦC,¦V¥kÂX®i39Äæ½d³òªºÀx¦s®æ,¥HBrr°}¦CÈˤJ
'Y("ªíÀY")Àx¦s®æ¸Ì¦³¤½¦¡!©Ò¥H»Ýn¥H°}¦Cȱa¤J
Set Brr = Nothing
Set Y = Nothing
'¡ôÄÀ©ñÅܼÆ
End Sub |
|