Please - Macro that deletes every second row 
Author Message
 Please - Macro that deletes every second row

Hello

May I please ask for your kind help?

I just spent a lot of time trying to write a VB macro that would start in
the first row of an Excel spreadsheet and delete every second row [i.e.
delete rows 2, 4, 6, etc], but for some reason it never works.  Could you
please help me with this?

Thank You very much

With Best Regards

Tina



Tue, 02 Mar 2004 13:20:59 GMT  
 Please - Macro that deletes every second row
Hi Tina,

If the relevant rows are definite, it may be better to delete the rows in
descending order, i.e. ..... 10,8,6,4,2.

Rgds,
Ricky


Quote:
> Hello

> May I please ask for your kind help?

> I just spent a lot of time trying to write a VB macro that would start in
> the first row of an Excel spreadsheet and delete every second row [i.e.
> delete rows 2, 4, 6, etc], but for some reason it never works.  Could you
> please help me with this?

> Thank You very much

> With Best Regards

> Tina



Tue, 02 Mar 2004 15:49:00 GMT  
 Please - Macro that deletes every second row
Hi Tina!

Let's see if you can do it with a tip.

Don't start at the top and work down. Start at the bottom and work up.

Post back if you need more help.

hth


Quote:
> Hello

> May I please ask for your kind help?

> I just spent a lot of time trying to write a VB macro that would start in
> the first row of an Excel spreadsheet and delete every second row [i.e.
> delete rows 2, 4, 6, etc], but for some reason it never works.  Could you
> please help me with this?

> Thank You very much

> With Best Regards

> Tina



Tue, 02 Mar 2004 15:59:47 GMT  
 Please - Macro that deletes every second row
Hi

Quote:
> Don't start at the top and work down. Start at the bottom and work up.

> Post back if you need more help.

I am sorry, i tried that, but I still cannot get it to work :(
Could you please help me with that?
Thank You

Quote:

> hth



> > Hello

> > May I please ask for your kind help?

> > I just spent a lot of time trying to write a VB macro that would start
in
> > the first row of an Excel spreadsheet and delete every second row [i.e.
> > delete rows 2, 4, 6, etc], but for some reason it never works.  Could
you
> > please help me with this?

> > Thank You very much

> > With Best Regards

> > Tina



Tue, 02 Mar 2004 22:36:34 GMT  
 Please - Macro that deletes every second row
You might be better of tagging the rows to be deleted, sorting
then deleting. This is by far the quickest method for large
worksheets.

It is assumed that you want to delete the rows, and not just
the contenct in the even numbered rows.

Make a backup copy of your workbook.

In a blank column, enter
=If(MOD(ROW(),2)=0,0,1)

Copy down to the last (used) row in your sheet.
Copy, Paste Special -- Values the formula column
created above.
Sort in ascending order using this tagged column.
Delete all rows tagged with zero.

| Hello
|
| May I please ask for your kind help?
|
| I just spent a lot of time trying to write a VB macro that would start in
| the first row of an Excel spreadsheet and delete every second row [i.e.
| delete rows 2, 4, 6, etc], but for some reason it never works.  Could you
| please help me with this?
|
| Thank You very much
|
| With Best Regards
|
|
| Tina
|
|



Tue, 02 Mar 2004 22:41:00 GMT  
 Please - Macro that deletes every second row
Try the macro below, assuming that those even rows are to be deleted from
the current region of cell 'A1'.

Sub delete_rows()
    Application.ScreenUpdating = False
    Cells(1, 1).Activate
    x = ActiveCell.CurrentRegion.Rows.Count
    For i = x To 1 Step -1
        If i Mod 2 = 0 Then Rows(i).Delete
    Next i
End Sub

Hope this may help.
Ricky


Quote:
> Hi

> > Don't start at the top and work down. Start at the bottom and work up.

> > Post back if you need more help.

> I am sorry, i tried that, but I still cannot get it to work :(
> Could you please help me with that?
> Thank You

> > hth



> > > Hello

> > > May I please ask for your kind help?

> > > I just spent a lot of time trying to write a VB macro that would start
> in
> > > the first row of an Excel spreadsheet and delete every second row
[i.e.
> > > delete rows 2, 4, 6, etc], but for some reason it never works.  Could
> you
> > > please help me with this?

> > > Thank You very much

> > > With Best Regards

> > > Tina



Tue, 02 Mar 2004 23:29:50 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. how to delete every second row

2. Deleting every second row?

3. delete every second row

4. Deleting every second row

5. Getting #deleted message in every field of every row when linking to a SQL Server DB

6. Deleting several rows every nth row

7. macro to insert new row every other row

8. duplicating every second row

9. inserting a row to every second line.

10. re : choose every second row


 
Powered by phpBB® Forum Software © phpBB Group