Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Delete Unused (4000) Rows

Help,
I have a Large workbook running multiple Macros to import, compare
and generate reports.
The Problem is that after all is said and done I endup with a workseet
that has about 5000 rows, when only maybe 1000 have data in them. The
other 4000 are blank, I nned to remove these as they increase the size
of the workbook exponentially. Since this worksheet has between 7 and
10 worksheets with the same problem.

Since I am deleting alout of rows I am also worried about the Macro
slowing down too much.
I already have Application.ScreenUpdating = False


Any Ideas or suggestions.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Delete Unused (4000) Rows

use something like:

With Sheets("sheet2")
.UsedRange
End With

If you've got a few sheets with consecutive numbers, you could try:

For i = 1 To Sheets.Count
With Sheets("sheet" & i)
.UsedRange
End With
Next


Regards

Trevor


"VexedFist" wrote in message
oups.com...
Help,
I have a Large workbook running multiple Macros to import, compare
and generate reports.
The Problem is that after all is said and done I endup with a workseet
that has about 5000 rows, when only maybe 1000 have data in them. The
other 4000 are blank, I nned to remove these as they increase the size
of the workbook exponentially. Since this worksheet has between 7 and
10 worksheets with the same problem.

Since I am deleting alout of rows I am also worried about the Macro
slowing down too much.
I already have Application.ScreenUpdating = False


Any Ideas or suggestions.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Delete Unused (4000) Rows

assume the last non empty cell in column A will determine where to start
deleting:

for each sh in ActiveWorkbook.worksheets
lastrow = sh.cells(sh.rows.count,1).End(xlup)(2).row
rows(lastrow & ":" & sh.rows.count).EntireRow.Delete
Next
ActiveWorkbook.Save

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"VexedFist" wrote:

Help,
I have a Large workbook running multiple Macros to import, compare
and generate reports.
The Problem is that after all is said and done I endup with a workseet
that has about 5000 rows, when only maybe 1000 have data in them. The
other 4000 are blank, I nned to remove these as they increase the size
of the workbook exponentially. Since this worksheet has between 7 and
10 worksheets with the same problem.

Since I am deleting alout of rows I am also worried about the Macro
slowing down too much.
I already have Application.ScreenUpdating = False


Any Ideas or suggestions.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Delete Unused (4000) Rows

Tom,

This seems to delete eveything except 1 row from my worksheet?


Tom Ogilvy wrote:
assume the last non empty cell in column A will determine where to start
deleting:

for each sh in ActiveWorkbook.worksheets
lastrow = sh.cells(sh.rows.count,1).End(xlup)(2).row
rows(lastrow & ":" & sh.rows.count).EntireRow.Delete
Next
ActiveWorkbook.Save

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"VexedFist" wrote:

Help,
I have a Large workbook running multiple Macros to import, compare
and generate reports.
The Problem is that after all is said and done I endup with a workseet
that has about 5000 rows, when only maybe 1000 have data in them. The
other 4000 are blank, I nned to remove these as they increase the size
of the workbook exponentially. Since this worksheet has between 7 and
10 worksheets with the same problem.

Since I am deleting alout of rows I am also worried about the Macro
slowing down too much.
I already have Application.ScreenUpdating = False


Any Ideas or suggestions.



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
How can i delete unused row and columns ??? Irfan Khan[_2_] Excel Discussion (Misc queries) 8 January 15th 08 07:26 PM
I have 4000+ rows in a worksheet, how to delete 100's at a time? Renee working on data Excel Worksheet Functions 4 September 12th 07 10:33 PM
How can i randomly select 780 rows from 4000 rows of data bbb Excel Worksheet Functions 2 July 6th 07 08:21 PM
VB Code to Delete Unused Rows Ken[_18_] Excel Programming 2 October 1st 04 04:35 AM
How can I insert 4000 rows of Excel data into a sql database skaty Excel Programming 0 July 31st 04 08:09 PM


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