|
楼主 |
发表于 2018-4-4 14:08
|
显示全部楼层
我对k用条件语句但是不对,但是没有思路去解决
Sub newadd2()
Dim wb As Workbook, wbb As Workbook, i As Long, j As Long, k As Variant
Dim myfile As String, mypath As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
mypath = ThisWorkbook.path & ""
myfile = Dir(mypath & "*.xlsx")
j = Sheets("sheet1").[a65535].End(xlUp).Row
For i = 2 To j
k = Cells(i, "a")
If myfile <> ThisWorkbook.Name And myfile <> k Then
Set wb = Workbooks.Add
wb.SaveAs ThisWorkbook.path & "\" & k & ".xlsx"
wb.Close False
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub |
|