crittenberry
New Member
- Joined
- Mar 29, 2016
- Messages
- 8
Hello,
I am using a macro that imports data from a third party source via a txt file. The data is then split into new worksheets based on an ID number. (The number of spreadsheets created will vary per run). This part of the macro runs perfectly. The issue I am having is when the macro tries to add new rows. This is what I am currently using for that part:
Invoice = Sheets.Count
For x = 3 To Invoice
Sheets(x).Select
Range("A1").Select
Rows("1:5").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next x
The first new worksheet goes fine; however, when it goes to the next sheet the macro returns the following error:
"Microsoft Excel can't insert new cells because it would push non-empty cells off the end of the worksheet. These cells might appear empty but have blank values, some formatting, or a formula. Delete enough rows or columns to make room for what you want to insert and then try again.
The rows are being added for formatting.
Any help would be greatly appreciated.
I am using a macro that imports data from a third party source via a txt file. The data is then split into new worksheets based on an ID number. (The number of spreadsheets created will vary per run). This part of the macro runs perfectly. The issue I am having is when the macro tries to add new rows. This is what I am currently using for that part:
Invoice = Sheets.Count
For x = 3 To Invoice
Sheets(x).Select
Range("A1").Select
Rows("1:5").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Next x
The first new worksheet goes fine; however, when it goes to the next sheet the macro returns the following error:
"Microsoft Excel can't insert new cells because it would push non-empty cells off the end of the worksheet. These cells might appear empty but have blank values, some formatting, or a formula. Delete enough rows or columns to make room for what you want to insert and then try again.
The rows are being added for formatting.
Any help would be greatly appreciated.