- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-11-28 08:30 ½s¿è
¦^´_ 6# missbb
§Ú¥ç´ú¸Õ¹L Hsieh ª©¤jªºµ{¦¡½X¡A¤@¤Á¥¿±`µL³_¡A
¦³¥i¯à¬O§A¦b¬¡¶Ã¯¶¡¤Á´«²¾Âà®É²£¥Íªº°ÝÃD¡C
¨ä¹ê GBKEE¡BHsieh ¨â¦ìª©¤jªº¸ÑÃD¦U¦³¨ä¤£¿ùªº¸àÄÀ¡C
§Ú±N¥¦Ì¤©¥H¥[µù¡A¶Kªþ¦p¤U¡A¨âªÌ¶¡¦U¦³¨ä¥©§®¤§³B¡A
«Üȱo§@¬°ÉÃè¡C- Option Explicit
- Sub Ex() ' GBKEE
- Dim Wb As Workbook, E As Variant, xPath As String, xi As Integer
-
- Set Wb = ThisWorkbook ' ¬¡¶Ã¯ :µ{¦¡½X©Ò¦bªº
- xPath = Wb.Path & "\" ' ¦sÀɪº¸ô®|¡FÄ´¦p¡G xPath : "D:\TXT\" : String
-
- With Wb.Sheets("password")
- For xi = 1 To Wb.Sheets.Count - 1 ' password ¤u§@ªí ©T©w¬¡¶Ã¯¤¤¦ì¸m³Ì«á±(©Ò¦³¤u§@ªíªº«á±)
- Wb.Sheets(xi + 1).Copy ' «ü©w¬Oþ¤@Ó¬¡¶Ã¯ªº¤u§@ªín½Æ»s
- ' Example: Worksheets("Sheet1").Copy After:=Worksheets("Sheet3")
- ' This example copies Sheet1, placing the copy after Sheet3.
- ' Remarks: If you don't specify either Before or After, Microsoft Excel creates a new workbook
- ' that contains the copied sheet.
- ActiveWorkbook.Sheets(1).UsedRange.Value = ActiveWorkbook.Sheets(1).UsedRange.Value ' ¦s¤å¦rªºÈ¤Î®æ¦¡
- ' FileFormat:=xlExcel8 Excel 2003ª©¥» 56; xlWorkbookDefault = Excel 2007, or 2010, or 2013.
- ActiveWorkbook.SaveAs Filename:=xPath & Wb.Sheets(xi + 1).Name & ".xls", Password:=Trim(.Cells(xi, "B")), WriteResPassword:="", FileFormat:=xlExcel8
- ' ActiveWorkbook.SaveAs Filename:=xPath & Wb.Sheets(xi + 1).Name & ".xlsx", Password:=Trim(.Cells(xi, "B")), WriteResPassword:="", FileFormat:=xlWorkbookDefault
- ActiveWorkbook.Close False ' Ãö³¬ "D:\A123.xls" ¬¡¶Ã¯¡B"D:\B456.xls" ¬¡¶Ã¯¡C
- Next
- End With
- End Sub
½Æ»s¥N½X ¦b Hsieh ª©¤jªºµ{¦¡½X¤¤¡AGBKEE ¼W¥[¤F Wb ªº¥[±j«Å§i¡A©ú½T¦a«ü¥X¬¡¶Ã¯ªºÄÝ©ÊÂkÄÝ¡C- Sub Ex2() ' Hsieh & GBKEE
- Dim f$, fd$, fs$, A As Range, Wb As Workbook
-
- Set Wb = ThisWorkbook ' ¬¡¶Ã¯ :µ{¦¡½X©Ò¦bªº
- fd = Wb.Path & "\" ' ¦sÀɪº¸ô®|
- With Wb.Sheets("PASSWORD")
- For Each A In .Range(.[A1], .[A1].End(xlDown))
- ' A : "A123" : Range/Range
- ' A : "B456" : Range/Range
- ' Sheets("PASSWORD").[A1] : "A123" : Variant/Object/Range
- ' Sheets("PASSWORD").[A1].End(xlDown) : "B456" : Variant/Object/Range
- f = CStr(A)
- fs = fd & f & ".xls"
- Wb.Sheets(f).Copy ' «ü©w¬Oþ¤@Ó¬¡¶Ã¯ªº¤u§@ªín½Æ»s
- ' Sheets(f).Copy °õ¦æ¹L«á¡A½Æ»s¤F¤@¬¡¶Ã¯¡A¤º¦³¤@¦W¬° "A123" ¤§¤u§@ªí³æ¡C
- ' ActiveWorkbook.Name : "¬¡¶Ã¯1" : String
- ' ActiveWorkbook.Sheets(1).Name : "A123" : Variant/String
- ' Sheets(f).Copy °õ¦æ¹L«á¡A½Æ»s¤F¤@¬¡¶Ã¯¡A¤º¦³¤@¦W¬° "B456" ¤§¤u§@ªí³æ¡C
- ' ActiveWorkbook.Name : "¬¡¶Ã¯2" : String
- ' ActiveWorkbook.Sheets(1).Name : "B456" : Variant/String
- With ActiveWorkbook
- .ActiveSheet.UsedRange = .ActiveSheet.UsedRange.Value
- ' FileFormat:=xlExcel8 Excel 2003ª©¥» 56; xlExcel12 version 12, or 14, or 15 = Excel 2007, or 2010, or 2013.
- .SaveAs Filename:=fs, Password:=CStr(A.Offset(, 1)), WriteResPassword:="", FileFormat:=xlExcel8
- .Close 0 ' Ãö³¬ "D:\A123.xls" ¬¡¶Ã¯¡B"D:\B456.xls" ¬¡¶Ã¯¡C
- End With ' ¥¿¦¡µ²§ô (Ãö³¬)¡C
- Next
- End With
- End Sub
½Æ»s¥N½X |
|