#1   Report Post  
khen1
 
Posts: n/a
Default macros

I'd like to create a macro that deletes every other row. When I record the
macro it only deletes the cell I used for recording. How do I make the macro
so it runs on any cell?
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

ilastrow = Cells(Rows.Count,"A") .row
if iLastRow Mod 2 < 0 then
iLastRow = iLastrow -1
End If
For i = ilastrowTo 1 Step 2
rows(i).delete
mext i

--
HTH

Bob Phillips

"khen1" wrote in message
...
I'd like to create a macro that deletes every other row. When I record the
macro it only deletes the cell I used for recording. How do I make the

macro
so it runs on any cell?



  #3   Report Post  
KL
 
Posts: n/a
Default

Hi khen1,

Try this:

Sub Test()
With ActiveSheet
For i = .Cells(.Rows.Count, "A"). _
End(xlUp).Row To 2 Step -2
.Rows(i).Delete
Next i
End With
End Sub


Regards,
KL


"khen1" wrote in message
...
I'd like to create a macro that deletes every other row. When I record the
macro it only deletes the cell I used for recording. How do I make the
macro
so it runs on any cell?



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
Protect macros? JulieD Excel Discussion (Misc queries) 6 August 25th 05 08:38 PM
sharing macros fabulousk Excel Discussion (Misc queries) 3 March 7th 05 10:05 PM
Enabling macros Peter M Excel Discussion (Misc queries) 3 February 7th 05 10:57 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM
The available macros list in XL; how to suppress filename from showing KR Excel Discussion (Misc queries) 1 January 10th 05 07:20 PM


All times are GMT +1. The time now is 02:39 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"