ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Resume on Error? (https://www.excelbanter.com/excel-programming/368171-resume-error.html)

dan

Resume on Error?
 
Hi, I am using this code to get rid of #DIV/0 and other errors:

Range("I5:Q29").Select
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
Selection.ClearContents

However, if there are no errors it stops my code from running and says
it found no cells. How can I have it say if there are none or if there
is an error from this then to skip it and just resume?

Thank you!!!


Chip Pearson

Resume on Error?
 
Dan,

Try

Range("I5:Q29").Select
On Error Resume Next
Selection.SpecialCells(xlCellTypeFormulas, xlErrors).Select
If Err.Number = 0 Then
Selection.ClearContents
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"dan" wrote in message
ups.com...
Hi, I am using this code to get rid of #DIV/0 and other errors:

Range("I5:Q29").Select
Selection.SpecialCells(xlCellTypeFormulas, 16).Select
Selection.ClearContents

However, if there are no errors it stops my code from running
and says
it found no cells. How can I have it say if there are none or
if there
is an error from this then to skip it and just resume?

Thank you!!!





All times are GMT +1. The time now is 02:03 AM.

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