How to return a comment depending on the date in the cell?

Manojlo

New Member
Joined
Sep 4, 2020
Messages
42
Office Version
  1. 365
Platform
  1. Windows
In column "A" I have different dates, and I want to have in column "B" comments "YES" or "NO" depends of dates in cells "A".
For example, all dates in May to return comment "YES" in column "B" and all other dates, after May, to return comment "NO".

1652252349918.png
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Do you just mean this or am I missing something:-
In A2 put
Excel Formula:
=IF(MONTH($A2)=5,"YES","NO")
 
Upvote 0
Try this:
VBA Code:
Sub Check_Dates()
'Modified 5/11/2022  4:35:33 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim mm As Long
mm = InputBox("Enter Month Number To Check For", "Enter Month Number", "5")
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Dim ans As Long
For i = 2 To Lastrow
ans = Month(Cells(i, 1).Value)
If ans = mm Then
Cells(i, 2).Value = "YES"
Else
Cells(i, 2).Value = "No"
End If
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Do you just mean this or am I missing something:-
In A2 put
Excel Formula:
=IF(MONTH($A2)=5,"YES","NO")

I need update, I need comments on date (month and year) before May 2022?

Do you know how to add a year also?
In case that I have some dates before 2022?
 
Upvote 0
Why "May"? Do you wish it to be "Jun" for next month?

Code:
=IF(EOMONTH(A2,0)=EOMONTH(TODAY(),0),"YES","NO")
 
Upvote 0
Why "May"? Do you wish it to be "Jun" for next month?

Code:
=IF(EOMONTH(A2,0)=EOMONTH(TODAY(),0),"YES","NO")
Maybe I did not well explain, sorry.
I need formula in column B (depend on date in column A) to receive return value depend on date. Condition are that all dates (before and current month and year also in cell C1 & D1) to have value YES, and all other month and year after current month to have value NO.

1652260672758.png
 
Last edited:
Upvote 0
You can probably figure out the last part yourself from my previous post but..
Excel Formula:
=IF(AND(YEAR($A2)=$D$1,MONTH($A2)=$C$1),"YES","NO")
 
Upvote 0
You can probably figure out the last part yourself from my previous post but..
Excel Formula:
=IF(AND(YEAR($A2)=$D$1,MONTH($A2)=$C$1),"YES","NO")
Tnx, with this formula I don't receive return "YES" on year before 2022?
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,258
Members
449,149
Latest member
mwdbActuary

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