LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default delete unused rows

Hi everyone,

Can someone tell me what is wrong with this syntax? To me it looks
fine but it doesn't delete the row within the selection it deleted
everything in the spreadsheet.


What I have done is:

* a range of cells (G19:G36) is named as range1
* another range (Xn:Xn) is named as rangen

towards the end of the sub it selects range1 with the following
code....

Range("range1").Select
Call delete_unusedrows

the syntax for delete_unusedrows is

-----------------------------------------------------------------------------------------------------
Sub delete_unusedrows()
On Error Resume Next

For Each cell In Selection

If cell.Offset(0, -6) = "R" Or cell.Offset(0, -6) = "E" Then
If cell = 0 Then
Cells.Rows.EntireRow.Delete = True
End If
End If

Next cell

End Sub
-----------------------------------------------------------------------------------------------------

One of the problems that I came across is that I am selecting the
"cell" where I'm verifying that the value = 0. I did a macro to test
if the cell = 0 worked and it appeared to have worked.

Thus.........

Why is it that when it gets to range1 it deletes everything rather
than what is in that selection?

I'm stumped......
 
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
macro to delete hidden or unused rows Cam Excel Programming 1 February 28th 08 08:35 PM
How can i delete unused row and columns ??? Irfan Khan[_2_] Excel Discussion (Misc queries) 8 January 15th 08 07:26 PM
Delete Unused (4000) Rows VexedFist[_2_] Excel Programming 3 September 22nd 06 09:54 PM
how to delete unused footer dialogs in excell Jaycee Excel Worksheet Functions 0 September 29th 05 08:07 PM
VB Code to Delete Unused Rows Ken[_18_] Excel Programming 2 October 1st 04 04:35 AM


All times are GMT +1. The time now is 10:20 PM.

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

About Us

"It's about Microsoft Excel"