Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Simple help with macro please

Can someone please give me a macro that will delete all rows in a worksheet
that do not include any data in column A up to a maximum of row 20?

Thanks
Brian Tozer


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Simple help with macro please

Brian,

Try something like the following:

Dim RowNdx As Long
For RowNdx = 20 To 1 Step -1
If Cells(RowNdx, "A").Value = "" Then
Rows(RowNdx).Delete
End If
Next RowNdx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Tozer" wrote in message
...
Can someone please give me a macro that will delete all rows in

a worksheet
that do not include any data in column A up to a maximum of row

20?

Thanks
Brian Tozer




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Simple help with macro please

One way:

Public Sub DelBlank()
On Error Resume Next
Range("A1:A20").SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
On Error GoTo 0
End Sub

the On Error statement prevents a run-time error if there are no
blank cells.


In article ,
"Brian Tozer" wrote:

Can someone please give me a macro that will delete all rows in a worksheet
that do not include any data in column A up to a maximum of row 20?

Thanks
Brian Tozer


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Simple help with macro please

Thanks so much Chip and J.E. for the very prompt help.
Now, as a teaching exercise for me, could you please show me how your macros
would be modified in the following two instances:-

1 To ignore (not delete) rows 5 to 8
2 To operate on all rows except 5 to 8 from row 1 to last row on worksheet
(presumably 65536)

Thanks again
Brian Tozer

J.E. McGimpsey wrote:
One way:

Public Sub DelBlank()
On Error Resume Next
Range("A1:A20").SpecialCells(xlCellTypeBlanks).Ent ireRow.Delete
On Error GoTo 0
End Sub

the On Error statement prevents a run-time error if there are no
blank cells.


In article ,
"Brian Tozer" wrote:

Can someone please give me a macro that will delete all rows in a
worksheet that do not include any data in column A up to a maximum
of row 20?

Thanks
Brian Tozer



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Simple help with macro please

You're asking for a teaching exercise for me and Chip, not for you.
So in that spirit, here's my teaching response:

Now, as a *learning* exercise for you, how have you tried to modify
the routines we gave you? Did the modifications work? What resources
did you look at in XL/VBA Help to try to come up with a solution?

Bonus points will be awarded if you checked the archives first:

http://google.com/advanced_group_search?q=group:*excel*


Don't get me wrong - I enjoy helping, but it's far more enjoyable
when those that seek help demonstrate that they've put some effort
in.



In article ,
"Brian Tozer" wrote:

Now, as a teaching exercise for me, could you please show me how your macros
would be modified in the following two instances:-

1 To ignore (not delete) rows 5 to 8
2 To operate on all rows except 5 to 8 from row 1 to last row on worksheet
(presumably 65536)

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
simple macro widman Excel Discussion (Misc queries) 7 June 7th 08 08:57 PM
Simple macro MikeD1224 Excel Discussion (Misc queries) 1 June 9th 07 12:06 AM
Simple (?) Macro NeedHelp Excel Discussion (Misc queries) 3 January 21st 07 10:39 PM
Simple Macro MAStew New Users to Excel 3 July 27th 06 10:50 PM
Need Simple Macro jreinert New Users to Excel 2 June 15th 06 03:58 PM


All times are GMT +1. The time now is 04:44 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"