Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
currentregion | Excel Discussion (Misc queries) | |||
CurrentRegion | Excel Programming | |||
CurrentRegion Selecting | Excel Programming | |||
CurrentRegion Failure. Please help! | Excel Programming | |||
CurrentRegion.copy maybe? | Excel Programming |