- ©«¤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
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-27 13:52 ½s¿è
¦^´_ 3# PJChen
ÁÂÁ«e½ú¦^´_
³o¨ÇÄݩʳ£¥i¥H¥Î¿ý»s¥¨¶°§Y¥i¨ú±o,¦]«á¾ÇÂǦ¹ÃD½m²ßVBA,¨Ã¥iÁYµu¬ã°Q¦¹¥DÃD±o¨ìµª®×,©Ò¥H«Øijª½±µ¥HVBA¤è®×
²LÂÅ©³¦â,Àx¦s®æ®æ¦¡®æ½u¿ï¶µ:
µ²ªG:
¥H¤U¬O«á¾Ç½m²ßVBA¤ß±oµù¸Ñ,½Ð°Ñ¦Ò
Option Explicit
Sub TEST_20221226_1()
Dim Area, T
'¡ô«Å§iÅܼÆ(Area,T)³£¬O³q¥Î«¬ÅܼÆ
T = [{"¸ê²£","¬y°Ê¸ê²£:","²{ª÷","À³¦¬²¼¾Ú","À³¦¬±b´Ú","¦s³f","¹w¥I´Ú¶µ","¨ä¥LÀ³¦¬´Ú","¨ä¥L¬y°Ê¸ê²£","¬y°Ê¸ê²£Á`p"}]
'¡ô¥OT³o³q¥Î«¬ÅܼƬO 10Ó¦r¦ê²Õ¦¨ªº°}¦C,¯Á¤Þ¸¹±q1¨ì10
T = Application.Transpose(T)
'¡ô¥OT³o³q¥Î«¬ÅܼƬO °}¦C¦Û¨Âà¸m«áªº¤Gºû°}¦C
Workbooks.Add
'¡ô¥Oµ{§Ç²£¥Í¤@Ó·s¬¡¶Ã¯
Set Area = [D2:E15]
'¡ô¥OArea³o³q¥Î«¬ÅܼƬO ·s¬¡¶Ã¯[D2:E15]Àx¦s®æ
With Area
'¡ô¥H¤U¬OÃö©óAreaÅܼƪº¬ÛÃöµ{§Ç
.Font.Name = "·L³n¥¿¶ÂÅé"
'¡ô¥O¦rÅé¦WºÙ¬O "·L³n¥¿¶ÂÅé"
.Font.ColorIndex = 49
'¡ô¥O¦r¦â¥N¸¹¬O 49
.HorizontalAlignment = xlLeft
'¡ô¥OÀx¦s®æ¤º®eÅã¥Ü¾a¥ª
.VerticalAlignment = xlTop
'¡ô¥OÀx¦s®æ¤º®eÅã¥Ü¾a¤W
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
'¡ô¥O°Ï°ìÀx¦s®æ¤º³¡¤ô¥®æ½u¬O¹ê½u
'xlContinuous= 1 : ³sÄò½u
.Borders(xlInsideHorizontal).ThemeColor = 1
'¡ô¥O°Ï°ìÀx¦s®æ¤º³¡¤ô¥®æ½uÃC¦â¬O¥Õ¦â
.Item(1).ColumnWidth = 20
'¡ô¥O°Ï°ìÀx¦s®æ²Ä1®æªºÄæ¼e¬O 20
.Item(2).ColumnWidth = 16
'¡ô¥O°Ï°ìÀx¦s®æ²Ä2®æªºÄæ¼e¬O 16
.Interior.ColorIndex = 2
'¡ô¥O°Ï°ìÀx¦s®æ©³¦â¬O ¥Õ¦â
.Item(5).Resize(2, 2).Interior.ColorIndex = 49
'¡ô¥O°Ï°ìÀx¦s®æ²Ä5®æ(§t¦Û¨)ÂX®i¦V¤U2¦C¦V¥k2Äæ°Ï°ìÀx¦s®æ,©³¦â¬OÂŦâ
.Item(5).Resize(2, 2).Merge
'¡ô¥O°Ï°ìÀx¦s®æ²Ä5®æ(§t¦Û¨)ÂX®i¦V¤U2¦C¦V¥k2Äæ°Ï°ìÀx¦s®æ¦X¨Ö
.Item(11).Resize(8, 2).Interior.ColorIndex = 37
'¡ô¥O°Ï°ìÀx¦s®æ²Ä11®æ(§t¦Û¨)ÂX®i¦V¤U8¦C¦V¥k2Äæ°Ï°ìÀx¦s®æ,©³¦â¬O²LÂŦâ
.Item(1) = "¤½¥q¦WºÙ"
'¡ô¥O°Ï°ìÀx¦s®æ²Ä1®æȬO "¤½¥q¦WºÙ"¦r¦ê
.Item(1).Font.Size = 16
'¡ô¥O°Ï°ìÀx¦s®æ²Ä1®æ¦r¤j¤p¬O 16
.Item(3) = "2022/3/31"
'¡ô¥O°Ï°ìÀx¦s®æ²Ä3®æȬO "2022/3/31"¦r¦ê
.Item(3).NumberFormatLocal = "¤é´Á:yyyy.mm.dd"
'¡ô¥O°Ï°ìÀx¦s®æ²Ä3®æ®æ¦¡¬O "¤é´Á:yyyy.mm.dd"
.Item(5) = "¸ê²£t¶Åªí"
'¡ô¥O°Ï°ìÀx¦s®æ²Ä5®æȬO "¸ê²£t¶Åªí"¦r¦ê
.Item(5).Font.ColorIndex = 2
'¡ô¥O°Ï°ìÀx¦s®æ²Ä5®æ¦r¦â¬O ¥Õ¦â
.Item(14, 1).Resize(1, 2).Borders(xlEdgeTop).Weight = 4
'¡ô¥O°Ï°ìÀx¦s®æ 14¦C1ÄæÀx¦s®æÂX®i¦V¤U1¦C¦V¥k2Äæ°Ï°ìÀx¦s®æ,¨ä¤W¤è®æ½u«¶q«Y¼Æ¬O4
.Item(14, 1).Resize(1, 2).Borders(xlEdgeTop).ThemeColor = 2
'¡ô¥O°Ï°ìÀx¦s®æ 14¦C1ÄæÀx¦s®æÂX®i¦V¤U1¦C¦V¥k2Äæ°Ï°ìÀx¦s®æÃC¦â¬O ¶Â¦â
.Item(14, 1).Font.Bold = True
'¡ô¥O°Ï°ìÀx¦s®æ 14¦C1ÄæÀx¦s®æ¦r¬O²ÊÅé
.Item(1).Font.Bold = True
'¡ô¥O°Ï°ìÀx¦s®æ²Ä1®æ¦r¬O²ÊÅé
.Item(9).Font.Bold = True
'¡ô¥O°Ï°ìÀx¦s®æ²Ä9®æ¦r¬O²ÊÅé
.Item(5, 1).Resize(10, 1) = T
'¡ô¥O°Ï°ìÀx¦s®æ 5¦C1ÄæÀx¦s®æÂX®i¦V¤U10¦C¦V¥k1Äæ°Ï°ìÀx¦s®æÈ,¥HT°}¦C±a¤J
End With
End Sub
Sub °}¦C»yªk´ú¸Õ()
Dim V, T, S, Z
V = Array("¸ê²£", "¬y°Ê¸ê²£:", "²{ª÷", "À³¦¬²¼¾Ú", "À³¦¬±b´Ú", "¦s³f", "¹w¥I´Ú¶µ", "¨ä¥LÀ³¦¬´Ú", "¨ä¥L¬y°Ê¸ê²£", "¬y°Ê¸ê²£Á`p")
T = [{"¸ê²£","¬y°Ê¸ê²£:","²{ª÷","À³¦¬²¼¾Ú","À³¦¬±b´Ú","¦s³f","¹w¥I´Ú¶µ","¨ä¥LÀ³¦¬´Ú","¨ä¥L¬y°Ê¸ê²£","¬y°Ê¸ê²£Á`p"}]
S = Split("¸ê²£,¬y°Ê¸ê²£:,²{ª÷,À³¦¬²¼¾Ú,À³¦¬±b´Ú,¦s³f,¹w¥I´Ú¶µ,¨ä¥LÀ³¦¬´Ú,¨ä¥L¬y°Ê¸ê²£,¬y°Ê¸ê²£Á`p", ",")
Z = Application.Transpose(T)
'¡ô¥OT³o³q¥Î«¬ÅܼƬO °}¦C¦Û¨Âà¸m«áªº¤Gºû°}¦C
MsgBox Z(2, 1)
MsgBox V(2) & " " & T(2) & " " & S(2)
MsgBox V(1) & " " & T(1) & " " & S(1)
MsgBox V(0) & " " & T(0) & " " & S(0)
End Sub
°»¿ù:
|
|