Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RC RC is offline
external usenet poster
 
Posts: 39
Default select alternate rows - quickly

I have a worksheet where I want to delete alternate rows. i.e. rows
1,3,5,7,9.......... because they contain no data. Currently I am holding the
control key and selecting every other row, then using the delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight alternate rows and
then just use the delete row button. I did create that macro but when using
it, instead of hilighting the alternate rows from where my cursor is inserted
it just hilights the same rows as when the macro was created (i.e. the wrong
rows).
How can I set something up that allows me to hilight alternate rows from
where I place my cursor.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default select alternate rows - quickly

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow To 1 Step -1
If row_index mod 2 =1 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub



-----Original Message-----
I have a worksheet where I want to delete alternate rows.

i.e. rows
1,3,5,7,9.......... because they contain no data.

Currently I am holding the
control key and selecting every other row, then using the

delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight

alternate rows and
then just use the delete row button. I did create that

macro but when using
it, instead of hilighting the alternate rows from where

my cursor is inserted
it just hilights the same rows as when the macro was

created (i.e. the wrong
rows).
How can I set something up that allows me to hilight

alternate rows from
where I place my cursor.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
RC RC is offline
external usenet poster
 
Posts: 39
Default select alternate rows - quickly

This appears to delete all the rows and not just the alternate ones as desired?

"Frank Kabel" wrote:

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow To 1 Step -1
If row_index mod 2 =1 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub



-----Original Message-----
I have a worksheet where I want to delete alternate rows.

i.e. rows
1,3,5,7,9.......... because they contain no data.

Currently I am holding the
control key and selecting every other row, then using the

delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight

alternate rows and
then just use the delete row button. I did create that

macro but when using
it, instead of hilighting the alternate rows from where

my cursor is inserted
it just hilights the same rows as when the macro was

created (i.e. the wrong
rows).
How can I set something up that allows me to hilight

alternate rows from
where I place my cursor.
.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default select alternate rows - quickly

Try this instead:

Code
-------------------

Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow To 1 Step -1
If IsEven(row_index) = False Then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub

-------------------



Then add this code to the module


Code
-------------------

Function IsEven(lngNum As Long) As Boolean
IsEven = Not CBool(lngNum Mod 2) 'test
End Function

-------------------


--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default select alternate rows - quickly

RC,
Works fine here.
Unless you have some data 1 line below the range you think you are
processing.

Nick

"RC" wrote in message
...
This appears to delete all the rows and not just the alternate ones as

desired?

"Frank Kabel" wrote:

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow To 1 Step -1
If row_index mod 2 =1 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub



-----Original Message-----
I have a worksheet where I want to delete alternate rows.

i.e. rows
1,3,5,7,9.......... because they contain no data.

Currently I am holding the
control key and selecting every other row, then using the

delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight

alternate rows and
then just use the delete row button. I did create that

macro but when using
it, instead of hilighting the alternate rows from where

my cursor is inserted
it just hilights the same rows as when the macro was

created (i.e. the wrong
rows).
How can I set something up that allows me to hilight

alternate rows from
where I place my cursor.
.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default select alternate rows - quickly

Hi
works for me

--
Regards
Frank Kabel
Frankfurt, Germany

"RC" schrieb im Newsbeitrag
...
This appears to delete all the rows and not just the alternate ones

as desired?

"Frank Kabel" wrote:

Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For row_index = lastrow To 1 Step -1
If row_index mod 2 =1 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub



-----Original Message-----
I have a worksheet where I want to delete alternate rows.

i.e. rows
1,3,5,7,9.......... because they contain no data.

Currently I am holding the
control key and selecting every other row, then using the

delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight

alternate rows and
then just use the delete row button. I did create that

macro but when using
it, instead of hilighting the alternate rows from where

my cursor is inserted
it just hilights the same rows as when the macro was

created (i.e. the wrong
rows).
How can I set something up that allows me to hilight

alternate rows from
where I place my cursor.
.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default select alternate rows - quickly

select a column where the only cells that are blank are in the rows you want
to delete.

Do
Edit=Goto = Special and select Blank Cells. Then do Edit=Delete and
select entire row.

This assumes the cells are actually blank and don't just appear blank
because they contain a formula returning an empty string or contain spaces.

--
Regards,
Tom Ogilvy

"RC" wrote in message
...
I have a worksheet where I want to delete alternate rows. i.e. rows
1,3,5,7,9.......... because they contain no data. Currently I am holding

the
control key and selecting every other row, then using the delete row

toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight alternate rows and
then just use the delete row button. I did create that macro but when

using
it, instead of hilighting the alternate rows from where my cursor is

inserted
it just hilights the same rows as when the macro was created (i.e. the

wrong
rows).
How can I set something up that allows me to hilight alternate rows from
where I place my cursor.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default select alternate rows - quickly

I'd love to know what is stopping you from sorting this?

Regards
Robert McCurdy

"If you can't, use Word"

"RC" wrote in message ...
I have a worksheet where I want to delete alternate rows. i.e. rows
1,3,5,7,9.......... because they contain no data. Currently I am holding the
control key and selecting every other row, then using the delete row toolbar
button. However I have many worksheets to do.
I thought I'd create a macro to automatically hilight alternate rows and
then just use the delete row button. I did create that macro but when using
it, instead of hilighting the alternate rows from where my cursor is inserted
it just hilights the same rows as when the macro was created (i.e. the wrong
rows).
How can I set something up that allows me to hilight alternate rows from
where I place my cursor.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.736 / Virus Database: 490 - Release Date: 09/08/2004


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
Select each alternate row in a worksheet Abdul Shakeel Excel Discussion (Misc queries) 1 August 8th 08 11:26 AM
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
reformating data- how to delete alternate blank rows quickly datamanipulator Excel Discussion (Misc queries) 4 November 27th 07 04:41 PM
quickly select data to produce charts kim Charts and Charting in Excel 1 March 8th 06 04:12 AM
Select alternate rows to copy Christina Excel Discussion (Misc queries) 4 January 27th 05 01:05 AM


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

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

About Us

"It's about Microsoft Excel"