VBA Macro to clear cell contents, but not the formula.

oblix

Board Regular
Joined
Mar 29, 2017
Messages
183
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I Have Tried this, but dont get it wright.
VBA Code:
Sub Clear_Perm1()
Worksheets("PERMENANT LIVING IN REGISTER").Range("C6:AV447").SpecialCells(xlCellTypeConstants, 23).ClearContents
Range("C1").Select

End Sub

What have I done Wrong?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
In what way doesn't it work?

In future please start a thread of your own, I have done that for you this time.
 
Upvote 0
Thank you for assistance.
It gives me a runtime error "1004"
 
Upvote 0
What is the error message?
 
Upvote 0
will the fact that some cells are protected cause this error?
 
Upvote 0
Depends, you haven't answered my question.
 
Upvote 0
Not sure then what the question was
I receive error 1004 message with description "No cells where found"
 
Upvote 0
It looks like it only gives this error if all cells are already blank
 
Upvote 0
I would not expect that error if the sheet was protected.
The error is saying that it can't find any cells.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,390
Messages
6,119,235
Members
448,879
Latest member
VanGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top