Error 13: for cell.ClearContents

Excel_VBA_YT

New Member
Joined
Aug 31, 2021
Messages
3
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi folks,

I am getting Error 13 while running the below code. If the contents of cell is New years day, I want to clear the cells contents.

The bold portion of the code is where the problem seems to be. any suggestions / advise would be great.
---------------------------------------------------------------
Sub Clear_contents()

Dim cell As Range
Dim myrange As Range
Set myrange = Worksheets("Step 1-3 Working Sheet").Range("M13:BA23")
myrange.UnMerge

For Each cell In myrange
If cell.Value = "New Years Day" Then
cell.ClearContents
End If

Next cell

End Sub
------------------------------------------------------------------
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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