Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Create a macro to delete rows if value is less than a specified nu | Excel Worksheet Functions | |||
resetting last cell | Excel Discussion (Misc queries) | |||
Add or Delete Rows in Protected worksheets | Excel Discussion (Misc queries) | |||
How do I delete checkboxes from rows I deleted in a macro? | Excel Discussion (Misc queries) | |||
Macro to delete rows with same data | Excel Worksheet Functions |