|
发表于 2019-11-13 17:41:33
|
显示全部楼层
- Sub sheets另存() '把所有工作表另存出去
- Dim sht As Worksheet
- For Each sht In Sheets
-
-
- sht.Copy
- ActiveWorkbook.SaveAs Filename:="d:\data" & sht.Name & ".xlsx"
- ActiveWorkbook.Close
-
- Next
- End Sub
- Sub del() '删除所有工作表
- Dim i As Integer
- Excel.Application.DisplayAlerts = False
-
- If Sheets.Count > 1 Then
-
- For i = 2 To Sheets.Count
- Sheets(2).Delete
- Next
- End If
- Excel.Application.DisplayAlerts = True
- End Sub
- Sub test1() '导入工作表
- Dim arr()
- Dim str As String
- Dim wb, wb1 As Workbook
- Set wb1 = ActiveWorkbook
-
-
- arr = Application.GetOpenFilename("excel文件,.xls*", 2, , , True)
- If arr(1) <> False Then
- For i = LBound(arr) To UBound(arr)
-
- Set wb = Workbooks.Open(arr(i))
-
- wb.Sheets(1).Copy after:=wb1.Sheets(wb1.Sheets.Count)
- wb1.Sheets(wb1.Sheets.Count).Name = Split(wb.Name, ".")(0)
-
-
- wb.Close
-
- Next
- End If
-
- End Sub
复制代码 |
|