Deleting successive rows on Excel 2007

5 pts.
Tags:
Excel 2007
Excel 2007 functions
Excel 2007 workbooks
Excel worksheets
Using VBA in a large timeline excel worksheet of 50000 rows. How can I automatically delete every 3 rows and leave the 4th row so I can reduce the number of rows to about 12,000.

Software/Hardware used:
excel 2007
ASKED: January 12, 2011  10:01 AM
UPDATED: January 12, 2011  2:39 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Try the macro here….
Sub XRows()
Dim Col As Integer
Dim St As Integer
Dim Cnt As Integer
Dim SRow As Integer
Dim I As Integer

SRow = 3 (because u wnat to delete every 3rd row)
Application.ScreenUpdating = False
Col = 1
Cnt = Selection.Rows.Count
For I = Col To Cnt Step SRow
St = I
Next

Do While St >= Col
Selection.Rows(St).Delete
St = St – Col
Loop
Application.ScreenUpdating = True
End Sub
NOTE: Take care about syntax.
For better information and a good <a href=”http://support.microsoft.com/kb/213610″>Guide here from Microsoft</a> .

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Chippy088
    I would suggest copying every 4th line to a new sheet, and delete the old sheet. This would be simpler to code in VBA.
    4,625 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following