Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2004, 02:19 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Deleting every other row

I need a macro that will delete every other row in excel. I tried this but no luck. If I just create a macro to delete a row it places a 2 where I have row. I just need to increment the row.

Sub delete()
' delete Macro
'
Dim row, endrow As Integer
row = 2
endrow = 120
'
If row < endrow Then
Rows("row:row").Select
Selection.delete Shift:=xlUp
    row = row + 1

End If

End Sub


 
Old December 15th, 2004, 05:20 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this
Sub delete()
' delete Macro
'
Dim row, endrow As Integer
row = 2
endrow = 120
'
Do while row < endrow
Rows("row:row").Select
Selection.delete Shift:=xlUp
    row = row + 2

loop

End Sub




Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a row of an array Singh591 VB.NET 2002/2003 Basics 1 July 23rd, 2007 04:51 PM
deleting row in a datagrid * nightmare :-( chrismogz ADO.NET 4 October 30th, 2006 05:47 PM
Deleting a row in excel sheet using c# livehed General .NET 1 May 17th, 2006 03:02 PM
problem in deleting the row from datagrid swati_joshi ASP.NET 1.0 and 1.1 Basics 10 March 24th, 2006 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.