- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-21 08:41 ½s¿è
¦^´_ 1# goner
ÁÂÁ«e½ú¦^´_»P¦Û¤v½m²ß½s¿èקï
¤µ¤Ñ«á¾Ç¦A½Æ²ß³o©«µo²{³\¦h¦Ò¶q¤£¨¬,¦b¾Ç²ß¤F¤@¦¸,¥H¤U¬O¤ß±oµù¸Ñ,½Ð°Ñ¦Ò,½Ð¦U¦ì«e½ú̦b«ü¾É¨ä¥L»yªk,ÁÂÁÂ
Option Explicit
Sub ¤u§@ªíÅã¥ÜÁôÂñ±¨î()
Application.ScreenUpdating = False
'¡ô¿Ã¹õ¼È¤£¸òÀHµ{§ÇÅܤưõ¦æµ²ªG
Dim N%, No%, i&, V, xR, Y, G1, G2, G3
'¡ô«Å§iÅܼÆ:(xR ,V, Y, G1, G2, G3)¬O³q¥Î«¬ÅܼÆ
'(N,No)¬Oµu¾ã¼ÆÅܼÆ,i¬Oªø¾ã¼Æ
No = InputBox("½Ð¿é¤J 0~4 ¼Æ¦r!", "¤u§@ªíÅã¥ÜÁôÂñ±¨î", 1)
'¡ô¥ONo¬O InputBox ¨ç¦¡,1¬O¹w¥ý¸m¤Jªº¼Æ¦r
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/inputbox-function
If No < 0 Or No > 4 Then Exit Sub
'¡ô¥O¦pªGNo³oµu¾ã¼ÆȤ£¬O0,1,2,3,4¤§¤@!,´Nµ²§ôµ{¦¡°õ¦æ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY¬O ¦r¨å
V = Sheets(1).[A1]
'¡ô¥OV³o³q¥Î«¬ÅܼƬO ²Ä¤@Ó¤u§@ªí[A1]Àx¦s®æÈ
V = Split(V, ",")
'¡ô¥OV³o³q¥Î«¬ÅܼÆÅܬ° ±N¦Û¤v³Q","²Å¸¹¤À³Îªº¤@ºû°}¦C
For Each xR In [{"A","B","C","D","E"}]
'¡ô³]¶¶°j°é!¥OxR³o³q¥Î«¬ÅܼƬO ¤@ºû°}¦C¸Ìªº¤@ÓÈ,±q«e±½ü¨ì³Ì«á
Y(xR) = Array(V(1 + N), V(2 + N), V(3 + N))
'¡ô¥OxR°j°éȬOkey,Item¬O¤@ºû°}¦C,¸Ì±¦³3ÓÈ,
'N¬Oµu¾ã¼Æ,ªì©lȬO0,©Ò¥H¤@¶}©lªº3ÓȬO[A1]Àx¦s®æȳQ¤À³Î«áªº¯Á¤Þ¸¹1,2,3Ó°}¦CÈ
N = N + 3
'¡ô¥ON²Ö¥[ 3
Next
For Each xR In ActiveWorkbook.Worksheets
'¡ô³]¶¶°j°é!¥OxR³o³q¥Î«¬ÅܼÆÅܬ°¦¹¤u§@¤¤¬¡¶³¡ªº¤u§@ªí¤§¤@,±q«e±½ü¨ì³Ì«á
xR.Visible = True
'¡ô¥OxR°j°é¤u§@ªíÅã¥Ü
Next
If No = 0 Then GoTo 111
'¡ô¦pªGNo³oµu¾ã¼ÆȬO 0,´N¸õ¨ì 111ªº¦ì¸mÄ~Äò°õ¦æ
Select Case No
'¡ô¨Ï¥Î Select Case ³¯z¦¡,ÀHµÛNo³oµu¾ã¼Æȹï·Ó¦¹³¯z¦¡¤º®e
'https://learn.microsoft.com/zh-tw/office/vba/language/concepts/getting-started/using-select-case-statements
Case 1: G1 = Y("C"): G2 = Y("D"): G3 = Y("E")
'¡ô¦pªGNo³oµu¾ã¼ÆȬO 1,´N¥OG1³o³q¥Î«¬ÅܼƬO ¥H"C"¦r¤¸¬d¦r¨åªº¨ìªº¤@ºû°}¦C,
'G2³o³q¥Î«¬ÅܼƬO ¥H"D"¦r¤¸¬d¦r¨åªº¨ìªº¤@ºû°}¦C,
'G3³o³q¥Î«¬ÅܼƬO ¥H"E"¦r¤¸¬d¦r¨åªº¨ìªº¤@ºû°}¦C
Case 2: G1 = Y("B"): G2 = Y("D"): G3 = Y("E")
'¡ôÃþ±À
Case 3: G1 = Y("B"): G2 = Y("C"): G3 = Y("E")
'¡ôÃþ±À
Case 4: G1 = Y("B"): G2 = Y("C"): G3 = Y("D")
'¡ôÃþ±À
End Select
Sheets(G1).Visible = False
'¡ô¥OG1³o³q¥Î«¬ÅܼƩұaªº°}¦C¦W¤u§@ªíÁôÂÃ
Sheets(G2).Visible = False
'¡ôÃþ±À
Sheets(G3).Visible = False
'¡ôÃþ±À
111
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
'¡ô¤u§@ªí¯Á¤Þ¼ÐÅÒ²¾¨ì³Ì«e¤è
Application.Goto Sheets(1).[A1]
'¡ôÀx¦s®æ´å¼Ð¸õ¨ì²Ä¤@Ó¤u§@ªí[A1]
Set Y = Nothing
Erase V
'¡ôÄÀ©ñÅܼÆ
End Sub
Sub UnhideAllSheets()
Dim UAS As Worksheet
For Each UAS In ActiveWorkbook.Worksheets
UAS.Visible = xlSheetVisible
Next UAS
End Sub
'°õ¦æ¤U¦Cµ{¦¡½X¥i¨ú±o 15Ó¤u§@ªí¦Wªº¦r¦ê
Sub ¦¬¶°15Ó¤u§@ªí¦W()
Dim i&, Na$
For i = 1 To 15
Na = Na & "," & Sheets(i).Name
Next
'Workbooks.Add
Sheets(1).[A1] = Na
'²Ä¤@Ó¤u§@ªí[A1]±a¤J 15Ó¤u§@ªí¦Wªº¦r¦ê
End Sub
'§â 15Ó¤u§@ªí¦Wªº¦r¦ê »P¤W¤è¬õ¦r¸m´«±¼ |
|