ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SpecialCells(xlCellTypeFormulas) (https://www.excelbanter.com/excel-programming/289425-specialcells-xlcelltypeformulas.html)

Kevin Gabbert

SpecialCells(xlCellTypeFormulas)
 
Hi guys. I'm looking for a way to keep the following line:

Set oRange = oSheet.Cells.SpecialCells(xlCellTypeFormulas)


from returning an error.

I do know that a similar line of code:

Set oRange = oSheet.Cells.SpecialCells(xlCellTypeBlanks)

can be kept from raising an error if I use the following undocumented excel featu

x = oSheet.Application.CountBlank(oRange)


...is there a similar one for xlCellTypeFormulas?

-K

Tom Ogilvy

SpecialCells(xlCellTypeFormulas)
 
If no cells meet the criteria, then specialcells returns an error.

The general approach is to trap the error.

Dim oRange as Range
On Error Resume Next
Set oRange = oSheet.Cells.SpecialCells(xlCellTypeFormulas)
On Error goto 0
if not oRange is Nothing then
' cells were found meeting the criteria
else
' cells were not found meeting the criteria
End if

--
Regards,
Tom Ogilvy

"Kevin Gabbert" wrote in message
om...
Hi guys. I'm looking for a way to keep the following line:

Set oRange = oSheet.Cells.SpecialCells(xlCellTypeFormulas)


from returning an error.

I do know that a similar line of code:

Set oRange = oSheet.Cells.SpecialCells(xlCellTypeBlanks)

can be kept from raising an error if I use the following undocumented

excel featu

x = oSheet.Application.CountBlank(oRange)


..is there a similar one for xlCellTypeFormulas?

-K





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com