Friday 25 October 2013

Excel Macro to get yesterday's date


Call getYesterday()


Sub getYesterday()
'We can use dateadd function to find yesterday's date in excel macro.

x = DateAdd("d", -1, Now)
MsgBox DateValue(x)
'In above function we have used dateadd function which takes 3 parameters.
'First parameter is used to specify the interval type like days, weeks, months, years etc.
'Second parameter is actual interval. It can be positive or negative
'Third parameter is any valid date.

'Similary We can find out the tommorrow's date using below line

x = DateAdd("d", 1, Now)
MsgBox DateValue(x)


End Sub


What do you think on above excel macro topic? Please provide your input, comments, questions on excel macro.  I will try to reply as soon as possible

No comments:

Post a Comment

Popular Posts

Search This Blog