raghuprabhu
New Member
- Joined
- Apr 8, 2017
- Messages
- 7
Hi,
The following code goes through the records and saves the workbook as the cell value in the column N.
The only problem is the last workbook created is not saving and is not closing.
Any suggestions would be helpful.
Thank you
Regards
Raghu
The following code goes through the records and saves the workbook as the cell value in the column N.
The only problem is the last workbook created is not saving and is not closing.
Code:
Sub SaveAsString()
Dim i As Integer
Dim lRow As Integer
Dim sPath As String
Dim sFileName As String
Dim wb As Workbook
sPath = ThisWorkbook.Path
lRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For i = 2 To lRow
sFileName = Range("N" & i).Value
ActiveWorkbook.SaveAs filename:=sPath & "\" & sFileName & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
Next i
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Any suggestions would be helpful.
Thank you
Regards
Raghu