Excel_VBA_YT
New Member
- Joined
- Aug 31, 2021
- Messages
- 3
- Office Version
- 365
- 2019
- Platform
- 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
------------------------------------------------------------------
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
------------------------------------------------------------------