Im trying to write a VBA script which edits a few cells, save the excel spreadsheet as a different name and as a csv file format. The issue I am having is repeating this process for multiple excel documents to be saved.
I have tried using a While loop however I have a feeling this stops working as soon as the first document is saved. The code works for the first excel spreadsheet but it doesn't make multiple files with different names.
Sub SaveFile()
Dim i As Integer
Dim c As Integer
Dim x As Integer
i = 1
x = InputBox("Enter the number of the Unit")
c = InputBox("How many Racks are in the Unit")
Do While i < c
If i < 10 Then
Cells(2, 4).Value = x & "0" & i & "01"
Cells(2, 6).Value = "RACK " & x & "0" & i & " /bal"
ActiveWorkbook.SaveAs Filename:="C:\Test\" & x & "0" & i & ".csv", FileFormat:=xlCSV
i = i + i
Else
Cells(2, 4).Value = x & i & "01"
Cells(2, 6).Value = "RACK " & x & i & " /bal"
ActiveWorkbook.SaveAs Filename:="C:\Test\" & x & i & ".csv", FileFormat:=xlCSV
i = i + i
End If
i = c
Loop
End Sub
What I expect it to do is create multiple spreadsheet files with different values in each as well as a different name for each file all as a CSV format. What is actually happening is only one document is created by the values are perfect.