ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Error Handling for xlCellTypeFormulas (https://www.excelbanter.com/excel-worksheet-functions/174160-error-handling-xlcelltypeformulas.html)

ccfcrup

Error Handling for xlCellTypeFormulas
 
Hi All

I am running some code that clears all the errors (#DIV/0!) in certain
columns. The code I am using is shown below:

Columns("AQ:BC").Select
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
Selection.ClearContents

The data in columns AQ:BC are dependent on source data from elsewhere.
If I do have errors the code works fine. However when there are no
errors I get a runtime error 1004 - no cells found. From reading
around i guess I need to have an error handler.

Can somebody please help?

Thanks

Rup

Dave Peterson

Error Handling for xlCellTypeFormulas
 
If you know that there could be errors, you could turn off error checking (for
as short a time as possible), try to do the work, and then turn error checking
back on.

on error resume next
Columns("AQ:BC").SpecialCells(xlCellTypeFormulas, 16).ClearContents
on error goto 0

But using "on error resume next" indescriminately is a very bad idea.

ccfcrup wrote:

Hi All

I am running some code that clears all the errors (#DIV/0!) in certain
columns. The code I am using is shown below:

Columns("AQ:BC").Select
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
Selection.ClearContents

The data in columns AQ:BC are dependent on source data from elsewhere.
If I do have errors the code works fine. However when there are no
errors I get a runtime error 1004 - no cells found. From reading
around i guess I need to have an error handler.

Can somebody please help?

Thanks

Rup


--

Dave Peterson


All times are GMT +1. The time now is 07:16 PM.

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