ExcelMoMan
New Member
- Joined
- Mar 28, 2017
- Messages
- 2
Hello -
I have a spreadsheet that contains 2400 rows and 2 columns. Column A has client notes that need to be saved as a text file (all 2400 rows need to be saved individually as a txt file), and Column B contains the name of the text file I would like. I worked on creating a macro for this and got to a good place and was able to export the first row, but when I tried to test it on the second row, it didn't work and now it won't work on the first row anymore either. I now get a VB Error: Run-time error '1004': Method 'SaveAs' of object '_Workbook' failed (Again, this worked fine before)
Does anyone know of any reason it would have stopped working? Additionally, I need help to automate this so that I can run the macro on all 2400 rows with one run of the macro. I am on a Mac, and am using Excel 2016. Here is the macro I used. When it worked, I got exactly what I needed for one row. I just need it to work for all rows, any help is appreciated.
I have a spreadsheet that contains 2400 rows and 2 columns. Column A has client notes that need to be saved as a text file (all 2400 rows need to be saved individually as a txt file), and Column B contains the name of the text file I would like. I worked on creating a macro for this and got to a good place and was able to export the first row, but when I tried to test it on the second row, it didn't work and now it won't work on the first row anymore either. I now get a VB Error: Run-time error '1004': Method 'SaveAs' of object '_Workbook' failed (Again, this worked fine before)
Does anyone know of any reason it would have stopped working? Additionally, I need help to automate this so that I can run the macro on all 2400 rows with one run of the macro. I am on a Mac, and am using Excel 2016. Here is the macro I used. When it worked, I got exactly what I needed for one row. I just need it to work for all rows, any help is appreciated.
Code:
Sub CopyToNew()
Application.DisplayAlerts = False
Dim Path As String
Path = "/Users/NAME/Desktop/Data/"
Range("A2:B2").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.SaveAs filename:=Path & Range("B1") & ".txt", FileFormat:=xlTextPrinter
'Get rid of filename column as it is not needed.
Columns("B:B").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'Save New Textfile
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub