How to assign the Value of Yesterday's Date to a String Variable in Visual Basic For Applications

This question is related a little related to a previous question in which I had asked how to get yesterdays date typed into a word document in response to the click event of a button on a VBA form.
The answer was
Selection.TypeText Format(Now - 1, "dd MMMM YYYY")
and this did work.
I would now like to be able to assign the value of yesterday's date to a string variable and would appreciate help for that.

So that if I say
Dim YesterdayDate As String
YesterdayDate = ?
( I need help what should come in place of ? so that the String Variable YesterdayDate becomes equal to Monday, 10 November 2008 assuming that today's date is Tuesday, 11 November 2008))
Thank you for your help in anticipation.
LVL 1
FaheemAhmadGulAsked:
Who is Participating?
 
leegclystvaleConnect With a Mentor Commented:
In fact ignore that, use yesterdaysdate = Format(now -1, "dddd, MMM d yyyy")
0
 
JohnGerhardtConnect With a Mentor Commented:
How about
Yesterday = Format(Now - 1, "dd MMMM YYYY")
0
 
leegclystvaleCommented:
Same concept as yestrerdaysdate = Date() -1
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
FaheemAhmadGulAuthor Commented:
Many thanks for the prompt response to my query. Both of the above solutions work. The one by JohnGerhardt shows date as 10 November 2008 and one by leegclystvale shows date as 10/11/2008.
Can any of the above solutions be modified a little so that the date also includes day of the week. So that the variable  YesterdaysDate becomes equal to Monday, 10 November 2008.
0
 
leegclystvaleCommented:
yesterdaysdate = Format(Now()-1, "Long Date")
0
 
FaheemAhmadGulAuthor Commented:
Excellent! This worked perfectly. Many thanks. As this required some extra work and both of you contributed to the solution, I have increased the total points to 250 and split them 150+100. I hope this is OK.
Once again thanking you both. Regards Faheem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.