Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saving a worksheet without empty rows

Hi,

I wonder if anyone can help with the following annoying problem.

I have a macro that writes hourly reports that may consist of up to
30,000 rows. At the end of each hour the contents of the worksheet are
written to a file. 30,000 rows are then deleted and the process starts
again.

My problem is, after the first hour I always write 30,000 rows to the
file, even if the last X thousand are empty.

Here is a snippet of the code:

Worksheets("StatsRecord").SaveAs Outfile
Worksheets("StatsRecord").Range("A3:U30000").Delet e

Can anyone tell me how I can force excel to only write the rows that
are populated?

Thanks

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Saving a worksheet without empty rows

In order to delete the used range:

Worksheets("StatRecord").UsedRange.Delete

This will delete Rows 1 & 2 also.

You could copy these two rows before deleting and paste them after.

"Matt Tyler" wrote:

Hi,

I wonder if anyone can help with the following annoying problem.

I have a macro that writes hourly reports that may consist of up to
30,000 rows. At the end of each hour the contents of the worksheet are
written to a file. 30,000 rows are then deleted and the process starts
again.

My problem is, after the first hour I always write 30,000 rows to the
file, even if the last X thousand are empty.

Here is a snippet of the code:

Worksheets("StatsRecord").SaveAs Outfile
Worksheets("StatsRecord").Range("A3:U30000").Delet e

Can anyone tell me how I can force excel to only write the rows that
are populated?

Thanks

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Saving a worksheet without empty rows

Once the old data has been deleted, save the empty file before new data is
collected. Excel will retain the original "Used Range" in the Undo buffer,
even though it is deleted, until the file is saved or closed.

Mike F
"Matt Tyler" wrote in message
om...
Hi,

I wonder if anyone can help with the following annoying problem.

I have a macro that writes hourly reports that may consist of up to
30,000 rows. At the end of each hour the contents of the worksheet are
written to a file. 30,000 rows are then deleted and the process starts
again.

My problem is, after the first hour I always write 30,000 rows to the
file, even if the last X thousand are empty.

Here is a snippet of the code:

Worksheets("StatsRecord").SaveAs Outfile
Worksheets("StatsRecord").Range("A3:U30000").Delet e

Can anyone tell me how I can force excel to only write the rows that
are populated?

Thanks

Matt



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving a worksheet without empty rows

Debra Dalgleish has some techniques (both manual and VBA) for resetting the used
range at:

http://www.contextures.com/xlfaqApp.html#Unused

Matt Tyler wrote:

Hi,

I wonder if anyone can help with the following annoying problem.

I have a macro that writes hourly reports that may consist of up to
30,000 rows. At the end of each hour the contents of the worksheet are
written to a file. 30,000 rows are then deleted and the process starts
again.

My problem is, after the first hour I always write 30,000 rows to the
file, even if the last X thousand are empty.

Here is a snippet of the code:

Worksheets("StatsRecord").SaveAs Outfile
Worksheets("StatsRecord").Range("A3:U30000").Delet e

Can anyone tell me how I can force excel to only write the rows that
are populated?

Thanks

Matt


--

Dave Peterson
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
unwanted empty rows at worksheet bottom Joe Miller Excel Discussion (Misc queries) 1 August 13th 06 07:46 PM
How do I specify an end to a worksheet to eliminate empty rows? Texasuser Excel Discussion (Misc queries) 2 January 24th 06 04:39 PM
empty rows at bottom of worksheet michael g Excel Discussion (Misc queries) 2 January 18th 05 09:17 PM
How to delete empty rows in a worksheet Bob Reynolds[_3_] Excel Programming 0 June 24th 04 11:04 PM
Delete empty rows in a worksheet Scott Excel Programming 3 January 8th 04 10:09 PM


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