Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Macro1 ()
Dim rng as Range, rng1 as Range For i = 1 To 100 n = 3 * i - 1 set rng = ActiveSheet.Rows(n).Resize(2) if not rng1 is nothing then set rng1 = union(rng1,rng) else set rng1 = rng end if Next rng1.Delete Shift:=xlUp End Sub -- Regards, Tom Ogilvy "GreenInIowa" wrote in message ... Thanks, Tom. I was not avare of of the fact that you could use "size( )" with Row ( ) object. My original plan was to select all the rows by a loop and then get out of the loop and delete them all at once, rather then reversing and deleting one at a time. Would it be not possible? "Tom Ogilvy" wrote: In complete correction. Should be Sub Macro1 () For i = 100 To 1 Step -1 n = 3 * i - 1 ActiveSheet.Rows(n).Resize(2).Select Selection.Delete Shift:=xlUp Next End Sub -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... Sub Macro1 () For i = 100 To 1 Step -1 n = 3 * i - 1 ActiveSheet.Rows(n, n + 1).Select Next Selection.Delete Shift:=xlUp End Sub -- Regards, Tom Ogilvy "GreenInIowa" wrote in message ... Hi, I am trying to delete bunch of empty rows, which are regularly spaced in my worksheet, using "FOR-NEXT" loop. But, it is giving me error. What I my I doing wrong here. Thanks. Sub Macro1 () For i = 1 To 100 n = 3 * i - 1 ActiveSheet.Rows("n, n + 1").Select Next Selection.Delete Shift:=xlUp End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula/Macro to delete rows that do not meet criteria from a list? | Excel Worksheet Functions | |||
If formula result is false, how do I auto-delete that rows? | Excel Worksheet Functions | |||
How to delete rows when List toolbar's "delete" isnt highlighted? | Excel Worksheet Functions | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming | |||
Delete #N/A rows Formula | Excel Programming |