Hi,
I have a file with thousands of rows. I created a macro to select 500 rows, copy past in new sheet, save as .txt and delete rows.
1) How do I increase the file name by one each time. So let's say I want to save it as Book1, Book2 etc.
2) how do I repeat it over and over again until all rows are deleted.
My Macro:
ActiveWindow.ScrollRow = 1
Range("A1:A500").Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\Users\myuser\Documents\Book1", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.SelectedSheets.Delete
ActiveWindow.ScrollRow = 1
Selection.Delete Shift:=xlUp
I have a file with thousands of rows. I created a macro to select 500 rows, copy past in new sheet, save as .txt and delete rows.
1) How do I increase the file name by one each time. So let's say I want to save it as Book1, Book2 etc.
2) how do I repeat it over and over again until all rows are deleted.
My Macro:
ActiveWindow.ScrollRow = 1
Range("A1:A500").Select
Selection.Copy
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:="C:\Users\myuser\Documents\Book1", _
FileFormat:=xlText, CreateBackup:=False
ActiveWindow.SelectedSheets.Delete
ActiveWindow.ScrollRow = 1
Selection.Delete Shift:=xlUp
Last edited: