#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default blank rows

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default blank rows

xlLastCell and Usedrange are both dependant on the state of the spreadsheet
when it was last saved... This makes both functions a little dangerous. You
are better off to use a function that moves up from the las cell in a column
sismlar to...

sheets("Sheet1").range("A65535").end(xlUp).offset( 1,0).select

This selects the first blank cell in Column A looking up from row 65,535.
You can change the sheet the the column and or the cell that you are looking
up from... So long as the bottom of the sheet is not "Ragged" then this works
great.

HTH

"Phil H" wrote:

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default blank rows

I like using the CurrentRegion for this, as it looks specifically for filled
cells. So Range("A1").CurrentRegion.Rows.Count tells me how many rows are
used in A; I can then insert the data into the next row. But this only works
(strictly speaking) for rectangular ranges of contiguous data.

"Phil H" wrote:

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default blank rows

xlLastCell and Usedrange are both dependant on the state of the spreadsheet
when it was last saved.

that is only partially true - you could say as a minimum, because it might
be greater.

Also, it is possible to make it smaller using code, but you should know if
you did that.

--
Regards,
Tom Ogilvy



"Jim Thomlinson" wrote in message
...
xlLastCell and Usedrange are both dependant on the state of the

spreadsheet
when it was last saved... This makes both functions a little dangerous.

You
are better off to use a function that moves up from the las cell in a

column
sismlar to...

sheets("Sheet1").range("A65535").end(xlUp).offset( 1,0).select

This selects the first blank cell in Column A looking up from row 65,535.
You can change the sheet the the column and or the cell that you are

looking
up from... So long as the bottom of the sheet is not "Ragged" then this

works
great.

HTH

"Phil H" wrote:

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default blank rows

Good idea, thanks!!

"K Dales" wrote:

I like using the CurrentRegion for this, as it looks specifically for filled
cells. So Range("A1").CurrentRegion.Rows.Count tells me how many rows are
used in A; I can then insert the data into the next row. But this only works
(strictly speaking) for rectangular ranges of contiguous data.

"Phil H" wrote:

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default blank rows

Jim, this works best for me. Thanks!!

"Jim Thomlinson" wrote:

xlLastCell and Usedrange are both dependant on the state of the spreadsheet
when it was last saved... This makes both functions a little dangerous. You
are better off to use a function that moves up from the las cell in a column
sismlar to...

sheets("Sheet1").range("A65535").end(xlUp).offset( 1,0).select

This selects the first blank cell in Column A looking up from row 65,535.
You can change the sheet the the column and or the cell that you are looking
up from... So long as the bottom of the sheet is not "Ragged" then this works
great.

HTH

"Phil H" wrote:

How do you append new rows to the end of a workbook?

If I find the last row using ActiveCell.SpecialCells(xlLastCell).Row and
append my stuff, I often find blank rows above the newly appended ones
because somebody had entered data and then cleared it, which moves the
LastCell downwards.

I am trying to delete the blank rows by looping thru all rows to detect
blank ones, but the IsBlank function won't work in VBA. Are there
workarounds?


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 do I delete blank rows (rows alternate data, blank, data, etc ncochrax Excel Discussion (Misc queries) 2 June 27th 07 04:40 AM
Copy rows of data (eliminating blank rows) from fixed layout Sweepea Excel Discussion (Misc queries) 1 March 13th 07 11:05 PM
Get number of rows that data takes up, including blank rows Denham Coote Excel Worksheet Functions 2 August 21st 06 09:18 AM
Delete blank row only if 2 consecutive blank rows Amy Excel Programming 2 October 21st 04 05:24 PM
Copying and pasting a worksheet to a blank and removing blank rows Bob Reynolds[_3_] Excel Programming 0 June 24th 04 02:55 PM


All times are GMT +1. The time now is 06:49 AM.

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"