Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default UsedRange and CurrentRegion

Hi,
I need to know realy last row and column, which contains data. I tried to
use UsedRange properties of object worksheet, but this is not what I want in
all real cases:

Sheets("Sheet1").usedrange.rows.count

UsedRange.rows.count properties count also rows only with some formatting
and with no data. Then I tried to use:

Sheets("Sheet1").usedrange.CurrentRegion.rows.coun t

and seems to work OK. Do the last code example find realy last row or column
or count of them in all cases, or is there some better way to get this always
?

Thanks for answer.
Tomas M.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default UsedRange and CurrentRegion

As you have discovered, UsedRange is the area of the sheet that has been
'Used' for any purpose, since it was last saved. CurrentRegion is the area
of contiguous cells surrounding the ActiveCell, that have data. You will
need to select whichever is appropriate for your needs at the time.
Mike F
"Tomas M." wrote in message
...
Hi,
I need to know realy last row and column, which contains data. I tried to
use UsedRange properties of object worksheet, but this is not what I want

in
all real cases:

Sheets("Sheet1").usedrange.rows.count

UsedRange.rows.count properties count also rows only with some formatting
and with no data. Then I tried to use:

Sheets("Sheet1").usedrange.CurrentRegion.rows.coun t

and seems to work OK. Do the last code example find realy last row or

column
or count of them in all cases, or is there some better way to get this

always
?

Thanks for answer.
Tomas M.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UsedRange and CurrentRegion

Current region will expand out to the first entirely blank row and column
(or edge of spreadsheet). So if you data is all in one block with no
embedded entirely blank rows or columns, it should give you the information
you want.

Another

lastrow = cells(rows.count,1).End(xlup).Row

this will only check values in column A (or the column you specify by
changing the 1). So if you have a specific column that you know will have a
value in the last filled row, then you can use this method as an
alternative.

--
Regards,
Tom Ogilvy

"Tomas M." wrote in message
...
Hi,
I need to know realy last row and column, which contains data. I tried to
use UsedRange properties of object worksheet, but this is not what I want

in
all real cases:

Sheets("Sheet1").usedrange.rows.count

UsedRange.rows.count properties count also rows only with some formatting
and with no data. Then I tried to use:

Sheets("Sheet1").usedrange.CurrentRegion.rows.coun t

and seems to work OK. Do the last code example find realy last row or

column
or count of them in all cases, or is there some better way to get this

always
?

Thanks for answer.
Tomas M.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default UsedRange and CurrentRegion

OK, if I understand this, UsedRange is maximally arrea, which I modified
anyway, inluded blank rows and columns, which are have some cells with some
formatting. And UsedRange.CurrentRegion included only that maximum area of
worksheet.UsedRange, when some data is in rows and columns through whole
worksheet, even when the data are in many areas and between that areas are
the rows or columns with no data. Other cells (out of area
UsedRange.CurrentRegion) can contain only some formating, but no data. If
this is correct expectation, it is what I want.

Tomas M.
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
currentregion flow23 Excel Discussion (Misc queries) 13 November 23rd 05 05:02 PM
CurrentRegion Steph[_3_] Excel Programming 2 August 10th 04 07:00 PM
CurrentRegion Selecting He4Giv Excel Programming 2 January 31st 04 07:13 PM
CurrentRegion Failure. Please help! John T Ingato Excel Programming 2 November 9th 03 11:12 PM
CurrentRegion.copy maybe? Bob Phillips[_5_] Excel Programming 5 September 7th 03 10:20 PM


All times are GMT +1. The time now is 11:07 AM.

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"