VBA to delete 94 rows from the current cell

prostreet

New Member
Joined
May 8, 2016
Messages
13
I have been trying to solve this for way to long by myself.
I'm attempting to create a vba macro to delete 94 rows in line.
I want to select a manually selected cell, then run a macro to delete the next 94 rows down.
Then select one row down and run the macro again.
I'm importing large amount of data and need to eliminate 94 rows at a time.
PLEASE, any and all suggestions would be appreciated by this 82 year old man.
Thank you in advance!
Jerome
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Posting your code would eliminate some guesswork. To describe the approach: get the row number you're on (e.g. 5) from the range object (the selected cell). Add 94 to that (99) and delete the rows in that range (A5:A99).

If you post code, please enclose in code tags (use vba button on posting toolbar) to maintain indentation and readability.
EDIT - since it's supposed to be dynamic, it's really the row that you're on plus 99, so "A5:A" & .Range.Row + 99
That's not verbatim since I'm presuming your code would allow you to just use .Range.Row like that. If not, you need a more explicit reference.
 
Last edited:
Upvote 0
Hi, here's one way you can try:

VBA Code:
Sub DEL94()
ActiveCell.Resize(94).EntireRow.Delete
End Sub
 
Upvote 0
Please try this out and, after testing on a dummy copy of your data, please let me know how it works for you

VBA Code:
Sub Ninety4Rows()


Dim rngCell As Range
Dim lngFirst As Long
Dim lngLast As Long
Dim lngLoop As Long

Set rngCell = ActiveCell

For lngLoop = 1 To 420 'set this to however many times you want to loop

   lngLoop = lngLoop + 1
   lngFirst = rngCell.Row
   lngLast = lngFirst + 94
   
   Range("A" & lngFirst & ":A" & lngLast).Delete
   
   Set rngCell = rngCell.Offset(0, 1)

Next lngLoop


End Sub
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: VBA to Delete a given number of rows.
There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Syntax would be closer to Range("A5:A" & activecell.row + 99).entirerow.delete
 
Upvote 0
Sounds like a possible solution.
Not at home currently.
Will try tomorrow AM.
Thank you for the response!
Jerome
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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