Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Macro for deleting every second Row of Data

hello
i am trying to use this macro for delete from my data every second ROW , but
couldn't use there is some error plz help me.
thanks in advance.

Sub abc()
Dim frow As Long, lrow As Long
Dim i As Long
frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Selection.Rows(A).Delete
Shift:=B:C
lShiftUp
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro for deleting every second Row of Data

Hi Tufail,

It is not clear from your code anf question whether your intention is to:

- delete every second column A cell in the selection

or to

- delete every second row in the selection.

In the first case try:

'=============
Public Sub abc()
Dim frow As Long, lrow As Long
Dim i As Long

frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Cells(i, "A").Delete Shift:=xlShiftUp
Next
End Sub
'<<=============

in the second case, try instead:

'=============
Public Sub abc2()
Dim frow As Long, lrow As Long
Dim i As Long

frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Rows(i).Delete Shift:=xlShiftUp
Next
End Sub
'<<=============

If your intention is not met by eitherof these suggestions, perhaps you
could endeavour to restate your requirements.


---
Regards,
Norman



"Tufail" wrote in message
...
hello
i am trying to use this macro for delete from my data every second ROW ,
but
couldn't use there is some error plz help me.
thanks in advance.

Sub abc()
Dim frow As Long, lrow As Long
Dim i As Long
frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Selection.Rows(A).Delete
Shift:=B:C
lShiftUp
Next

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for deleting every second Row of Data


Sub abc()

Dim frow As Long, lrow As Long
Dim i As Long

frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row

For i = lrow To frow Step -2

Rows(i).Delete

Next

End Sub


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=555914

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro for deleting every second Row of Data

Sub abc()
Dim frow As Long, lrow As Long
Dim i As Long
frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Rows(i).Delete
Next

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Tufail" wrote in message
...
hello
i am trying to use this macro for delete from my data every second ROW ,

but
couldn't use there is some error plz help me.
thanks in advance.

Sub abc()
Dim frow As Long, lrow As Long
Dim i As Long
frow = Selection.Row
lrow = Selection.Rows(Selection.Rows.Count).Row
For i = lrow To frow Step -2
Selection.Rows(A).Delete
Shift:=B:C
lShiftUp
Next

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
Deleting code from a macro (by a macro) Brettjg Excel Discussion (Misc queries) 2 May 8th 07 10:14 PM
Deleting cell data without deleting formula Tom Hall Excel Discussion (Misc queries) 4 October 29th 06 04:07 PM
Deleting unwanted data by macro or... Leibtek Excel Discussion (Misc queries) 2 August 14th 06 05:22 PM
Deleting excess data in a macro ChuckW Excel Discussion (Misc queries) 3 February 24th 05 06:48 PM
Excel – Macro Problem – Inserting, Appending Data, Deleting Aussiexcel[_3_] Excel Programming 0 August 25th 04 07:48 AM


All times are GMT +1. The time now is 08:02 AM.

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

About Us

"It's about Microsoft Excel"