If cell value is current end-of-month, clear contents

fruela

New Member
Joined
Oct 23, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi all, newbie on vba here, if cell value is current end-of-month how to clear cell contents?

This is for a column full of dates.

For range AF2:AF
If cell value =EOMONTH(TODAY();0)
Clear Cell Contents

or

For range AF2:AF
If cell value = AE2
Clear Cell Contents

Cheers
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Something like this
VBA Code:
Sub ClearCells()
    Dim C As Range
    For Each C In Range("AF:AF")
        If C.Value = Application.WorksheetFunction.EoMonth(C.Value, 0) Then C.ClearContents
    Next C
End Sub
 
Upvote 0
Something like this
VBA Code:
Sub ClearCells()
    Dim C As Range
    For Each C In Range("AF:AF")
        If C.Value = Application.WorksheetFunction.EoMonth(C.Value, 0) Then C.ClearContents
    Next C
End Sub

Hi Momentman, thank you for your help. I just read searched about WorksheetFunction and this makes total sense.

However when I run it I get the error: "Unable to get the EoMonth property of the WorksheetFunction class" :unsure:
 
Upvote 0
Hi Momentman, thank you for your help. I just read searched about WorksheetFunction and this makes total sense.

However when I run it I get the error: "Unable to get the EoMonth property of the WorksheetFunction class" :unsure:
Are you using the code exactly as you have it above?
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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