ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete (https://www.excelbanter.com/excel-programming/307449-delete.html)

tim

Delete
 
Hello All,
I would like to write some code that goes through all the
worksheets in a book and deletes any "hard-coded"
numbers. I would like it to leave all the titles and
headings and formulas.

Thanks in advance

Norman Jones

Delete
 
Hi Tim,

Try:

Sub TesterA01()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next
ws.Cells.SpecialCells(xlConstants, _
xlNumbers).Delete
On Error GoTo 0
Next ws
End Sub


---
Regards,
Norman



"Tim" wrote in message
...
Hello All,
I would like to write some code that goes through all the
worksheets in a book and deletes any "hard-coded"
numbers. I would like it to leave all the titles and
headings and formulas.

Thanks in advance




Tom Ogilvy

Delete
 
for each sh in workbook.worksheets
On error resume next
sh.cells.specialcells(xlconstants,xlnumbers).Clear Contents
On error goto 0
Next

would be a start.

--
Regards,
Tom Ogilvy

"Tim" wrote in message
...
Hello All,
I would like to write some code that goes through all the
worksheets in a book and deletes any "hard-coded"
numbers. I would like it to leave all the titles and
headings and formulas.

Thanks in advance




Norman Jones

Delete
 
Hi Tim,

Typo:

Change Delete to ClearConteb=nts.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Tim,

Try:

Sub TesterA01()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next
ws.Cells.SpecialCells(xlConstants, _
xlNumbers).Delete
On Error GoTo 0
Next ws
End Sub


---
Regards,
Norman



"Tim" wrote in message
...
Hello All,
I would like to write some code that goes through all the
worksheets in a book and deletes any "hard-coded"
numbers. I would like it to leave all the titles and
headings and formulas.

Thanks in advance






Norman Jones

Delete
 
Too hasty in correcting the typo!

Change Delete to ClearConteb=nts.



Should be:

Change Delete to ClearContents


The original typo was a stupidity on my part, probably due to a subconscious
retention of the the title of your post.

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Tim,

Typo:

Change Delete to ClearConteb=nts.


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Tim,

Try:

Sub TesterA01()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next
ws.Cells.SpecialCells(xlConstants, _
xlNumbers).Delete
On Error GoTo 0
Next ws
End Sub


---
Regards,
Norman



"Tim" wrote in message
...
Hello All,
I would like to write some code that goes through all the
worksheets in a book and deletes any "hard-coded"
numbers. I would like it to leave all the titles and
headings and formulas.

Thanks in advance









All times are GMT +1. The time now is 12:17 AM.

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