Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I need a macro that will delete every other row in excel.

I tried the following but no luck. If I just create a macro to delete a row
it places a 2 where I have the variable 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default I need a macro that will delete every other row in excel.

Sub delete()
' delete Macro
'
Dim startrow as long, endrow As long
Dim rw as Long
startrow = 2
endrow = 120
'
for rw = endrow to row step -1
Rows(rw).delete Shift:=xlUp
Next
End If
End Sub



or
Sub Delete()
dim startrow as long, endrow as Long
startrow = 2
endrow = 120
rows(startrow).Resize(endrow - startrow + 1) _
.entireRow.Delete
End Sub

--
Regards,
Tom Ogilvy

"Russ T" <Russ wrote in message
...
I tried the following but no luck. If I just create a macro to delete a

row
it places a 2 where I have the variable 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Delete VB Macro Ty Excel Worksheet Functions 9 August 10th 09 03:31 PM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
Delete records using excel Macro Ken Wright Excel Programming 1 November 3rd 03 08:01 PM
Delete records using excel Macro Nick Hodge[_4_] Excel Programming 0 November 3rd 03 07:31 PM
How to delete an Excel Macro from VBScript Ram[_3_] Excel Programming 1 September 3rd 03 11:18 PM


All times are GMT +1. The time now is 03:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"