![]() |
Range ... how to know if it is empty
Hi,
I'm using COM automation inside an xll to program Excel. At one point in the code, I do the following to retreive a Range of cells : "range = range.GetResize(COleVariant(rows), COleVariant(cols));" Is there a way (other than iterate over all the cells in the range) to know if the range is empty? Thanks. By the way, is there a place where I can find some documentation of those Excel Ole object? Nic |
Range ... how to know if it is empty
You can count the number of occupied cells and see if it is zero. For
instance: If Application.COUNTA(TheRange) = 0 Then ............. HTH Otto wrote in message oups.com... Hi, I'm using COM automation inside an xll to program Excel. At one point in the code, I do the following to retreive a Range of cells : "range = range.GetResize(COleVariant(rows), COleVariant(cols));" Is there a way (other than iterate over all the cells in the range) to know if the range is empty? Thanks. By the way, is there a place where I can find some documentation of those Excel Ole object? Nic |
Range ... how to know if it is empty
have a look at the specialcells property of a range. You may find one of these will answer your needs. eg: Set rngb = rnga.SpecialCells(xlCellTypeBlanks) Regards, -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=505366 |
Range ... how to know if it is empty
Thanks, it works great.
And what if I have another representation of the Range like an XLOPER array. _result.xltype = xltypeMulti; _result.val.array.lparray = xlValues; where xlValues is an array of XLOPER - Is there a way to take the array, make a COM Range object and call the COUNTA function? - Or should I loop over all elements of the array - Or is there another undocumented C Api function for this ;-) Thanks, Nic |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com