Loop (repeat) macro 100 times- Delete 1 Million rows

bloodybrit90

Board Regular
Joined
Jul 18, 2011
Messages
111
Hi guys, I need to repeat the below code 100 times each time I click it. I have a spreadsheet with over 1,000,000 rows and throusands of columns. I am trying to delet the rows out. When I attempt to delet all the rows at once I get a message stating too much info is selected. If you know a better way, please share.

Sub Delete_empty()
'
' Delete_empty Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
Rows("91:219").Select
Range("D91").Activate
Selection.Delete Shift:=xlUp
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try without selecting

Code:
Sub Delete_empty()
'
' Delete_empty Macro
'
' Keyboard Shortcut: Ctrl+Shift+D
'
Rows("91:219").Delete
End Sub
 
Upvote 0
The issue is this takes forever to delete all the rows. Only 128 rows are being deleted at once. Am I missing something? Sorry I am new to VBA.
 
Upvote 0
Instead of "91:219" enter the row numbers that you want to delete.
 
Upvote 0
The issue is this takes forever to delete all the rows. Only 128 rows are being deleted at once. Am I missing something? Sorry I am new to VBA.
Let's go back to Step #1... why are you deleting one million rows in the first place? Do you have data below them that you are trying to bring up to the top? Or are you just attempting to clear the worksheet? Or something else? (My thought is you might need to be Clear'ing the one million rows and cut/pasting any remaining data for the first case or simply Clear'ing all the cells outright.)
 
Last edited:
Upvote 0
I inherited this worksheet and it was running slow. THere was no data past cell 91, so I am not sure why there were so many rows in the first place. By deleting the unsued rows I thought the spreadsheet will run better. Thanks for all the help.
 
Upvote 0

Forum statistics

Threads
1,215,647
Messages
6,126,005
Members
449,280
Latest member
Miahr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top