I need help writing one line of code in VBA to return the Month-Ending date. The logic for Month-Ending date works like this...
If the last day of the month ends on...
Sunday: Then last day of that month is that previous Saturday. (Yesterday)
Monday: Then last day of that month is that previous Saturday. (2 days ago)
Tuesday: Then last day of that month is that previous Saturday. (3 days ago)
Wednesday:Then last day of that month is the upcoming Saturday (3 days in the future)
Thursday: Then last day of that month is the upcoming Saturday (2 days in future)
Friday: Then last day of that month is the upcoming Saturday (1 day in future)
My current code is below. The formatting of the Month-Ending date is as follows. 2016-07-02
Sub Macro1()
With ActiveWorkbook.Connections("ABC Query").ODBCConnection
.BackgroundQuery = True
.CommandText = Array( _
"exec [dbo].[getBSC_Monthly] @MonthEndDate = **where I need the line of code**")