Excel Delete Every Nth Row

In Resonse to a Question, ProfessorJimJam provided some excellent code for Deleting Every Nth Column. So I attempted to modify the code to Delete Every Nth Row:
Sub EveryNthRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "DeleteRow"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter Row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(1, i)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Delete
End Sub

Open in new window

But I get a Run Time Error on the last line of code before the END SUB
The Error is:  "Cannot Use That Command On Overlapping Selections".
I can't find where the error is or how to fix it.

Any assistance or insight would be greatly appreciated.

Tosagua.
================
Prior related question: http:Q_28682022.html
TosaguaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anne TroyEast Coast ManagerCommented:
Hi, Tosagua!

Seems you may want to accept Jim's solution if you're going to use his code for further questions.

Just saying. :)
0
TosaguaAuthor Commented:
Dreamboat,

We did award partial credit, but were hoping to award full credit for a possible answer on this question.
His answer is great for smaller spreadsheets, but we needed to finish a macro that would be used for spreadsheets in excess of 205 columns.

Tosagua
0
ProfessorJimJamCommented:
Use this

Sub EveryNthRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "Deleterow"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(i, 1)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Delete
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TosaguaAuthor Commented:
I am sorry about this, but I accepted your solution and awarded the points last week. Unfortunately, I am stuck using Internet Explorer 8, which doesn’t work well on Experts Exchange, while IE 11 continually crashes.

Tosagua
0
ProfessorJimJamCommented:
no problem,

glad to help.  thanks for the feedback.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.