Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
BB BB is offline
external usenet poster
 
Posts: 39
Default need macro script - repeat to delete 2 rows

I need to repeat deleting 2 rows, skipping 1 row, then deleting 2 rows again
and skipping 1 row.

How to run macro on this? Please help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default need macro script - repeat to delete 2 rows

Try:

Sub delete_rows()

Dim r As Range, j As Long

Set r = ActiveSheet.UsedRange
j = r.Rows.Count + r.Row
Set rdel = Cells(j, "A")

k = 0
For i = 1 To j - 1
k = k + 1
If k = 4 Then
k = 1
End If
If k = 3 Then
Else
Set rdel = Union(rdel, Cells(i, "A"))
End If
Next
rdel.EntireRow.Delete

End Sub

--
Gary's Student


"BB" wrote:

I need to repeat deleting 2 rows, skipping 1 row, then deleting 2 rows again
and skipping 1 row.

How to run macro on this? Please help.

  #3   Report Post  
Posted to microsoft.public.excel.misc
BB BB is offline
external usenet poster
 
Posts: 39
Default need macro script - repeat to delete 2 rows

Thank you. It works, however it delete the columns and keep each row of
column D. I need all info in the row.

How do you figure it out this complicated script? Can you show me how to
use record and stop record in macro easy steps?

"Gary''s Student" wrote:

Try:

Sub delete_rows()

Dim r As Range, j As Long

Set r = ActiveSheet.UsedRange
j = r.Rows.Count + r.Row
Set rdel = Cells(j, "A")

k = 0
For i = 1 To j - 1
k = k + 1
If k = 4 Then
k = 1
End If
If k = 3 Then
Else
Set rdel = Union(rdel, Cells(i, "A"))
End If
Next
rdel.EntireRow.Delete

End Sub

--
Gary's Student


"BB" wrote:

I need to repeat deleting 2 rows, skipping 1 row, then deleting 2 rows again
and skipping 1 row.

How to run macro on this? Please help.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default need macro script - repeat to delete 2 rows

Using the recorder to automate what you do manually is a very good start.
The recorder is not good for teaching about loops or conditional statements.
It goes not help to learn about ranges either.

Get the VBA for dummies book
checkout:

http://www.functionx.com/vbaexcel/index.htm
--
Gary's Student


"BB" wrote:

Thank you. It works, however it delete the columns and keep each row of
column D. I need all info in the row.

How do you figure it out this complicated script? Can you show me how to
use record and stop record in macro easy steps?

"Gary''s Student" wrote:

Try:

Sub delete_rows()

Dim r As Range, j As Long

Set r = ActiveSheet.UsedRange
j = r.Rows.Count + r.Row
Set rdel = Cells(j, "A")

k = 0
For i = 1 To j - 1
k = k + 1
If k = 4 Then
k = 1
End If
If k = 3 Then
Else
Set rdel = Union(rdel, Cells(i, "A"))
End If
Next
rdel.EntireRow.Delete

End Sub

--
Gary's Student


"BB" wrote:

I need to repeat deleting 2 rows, skipping 1 row, then deleting 2 rows again
and skipping 1 row.

How to run macro on this? Please help.

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
Create a macro to delete rows if value is less than a specified nu QE Excel Worksheet Functions 5 July 27th 06 09:35 PM
resetting last cell jagdish.eashwar Excel Discussion (Misc queries) 11 March 31st 06 03:06 AM
Add or Delete Rows in Protected worksheets NH Excel Discussion (Misc queries) 0 March 16th 06 06:15 PM
How do I delete checkboxes from rows I deleted in a macro? Jazzi-D Excel Discussion (Misc queries) 1 January 18th 06 01:49 AM
Macro to delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 02:18 PM


All times are GMT +1. The time now is 05:25 PM.

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"