我有一些代码试图在循环中执行,因此它会保存位于单元格列表中的具有不同名称的文件
我使用了下面的代码。它按预期保存,但现在我不知道如何让它继续下降到“E5”
Private Sub Save_Click()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "p:"
FileName = Sheet10.Range("E4").Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Application.DisplayAlerts = True
End Sub
For
子句中更改开始值和结束值Private Sub Save_Click()
Dim FileName As String
Dim Path As String, i As Long
Application.DisplayAlerts = False
Path = "p:"
For i = 4 To 10 ' modify as needed
FileName = Sheet10.Range("E" & i).Value & ".xlsx"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook
Next
Application.DisplayAlerts = True
End Sub