ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all cells with a "x" in them (https://www.excelbanter.com/excel-programming/278451-re-delete-all-cells-x-them.html)

BrianB

Delete all cells with a "x" in them
 
You are using the wrong code. It should be :-
'-------------------------------------
Sub test()
For Each c In Sheets("CDPTS").Range("B1:B363").Cells
If c.Value = "x" Then
c.ClearContents
End If
Next
End Sub
'------------------------------------------

It is bad programming practice to use a 'reserved word' in a macro. In
this case "Cell" already has meaning in VBA. You may get away with it
sometimes, but this can cause chaos in a large program - or when Excel
decides it has had enough.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 01:59 AM.

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