|
请各位老师帮忙
我用EXCEL XLS文件运行以下代码,现在是保存EXCEL XLS文件,我想修改运行以下代码保存EXCEL XLSX文件,( .SaveAs ThisWorkbook.Path & "\" & nm1 & ".xls", 18)我尝试修改( .SaveAs ThisWorkbook.Path & "\" & nm1 & ".xlsx", 18好像不可以)请各位老师帮忙修改,谢谢
ActiveWorkbook.Save
Application.ScreenUpdating = True
Dim Arr, i&, wb As Workbook, nm1$
Dim d, k, t, j&, aa
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
Set wb = ThisWorkbook
Sheet1.Activate
Arr = [a1].CurrentRegion
For i = 2 To UBound(Arr)
d(Arr(i, 6)) = d(Arr(i, 6)) & i & ","
Next
k = d.keys: t = d.items
For i = 0 To UBound(k)
nm1 = k(i)
Workbooks.Add
With ActiveWorkbook
With .Sheets(1)
.Cells.NumberFormatLocal = "@"
.Select
.[a1].Resize(1, UBound(Arr, 2)) = Application.Index(Arr, 1, 0)
t(i) = Left(t(i), Len(t(i)) - 1)
If InStr(t(i), ",") Then
aa = Split(t(i), ",")
For j = 0 To UBound(aa)
.Cells(j + 2, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, aa(j), 0)
Next
Else
.Cells(j + 2, 1).Resize(1, UBound(Arr, 2)) = Application.Index(Arr, t(i), 0)
End If
.Cells.EntireColumn.AutoFit
End With
.SaveAs ThisWorkbook.Path & "\" & nm1 & ".xls", 18
.Close
j = 0
End With
Next
End Sub
|
|