Excel Macro for Yesterday

I frequently use the shortcut Ctr + ; to enter today’s date in a cell. I thought it would be useful to be able to enter yesterday’s date in a cell. I wrote a one-line macro to do it for me.

The macro is

Sub Yesterday()
If TypeName(Selection) = "Range" Then Selection.Value = Date - 1
End Sub

This will only enter yesterday’s date if you have selected a cell or a range before running the macro.

If you want a formula for yesterday then see the post below.

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.