nniedzielski
Well-known Member
- Joined
- Jan 8, 2016
- Messages
- 598
- Office Version
- 2019
- Platform
- Windows
I am running a Macro that takes todays date, alters and formats it as such 07 04 18. Goes into an object, enters the date this way, scrapes data and enters into onto my spreadsheet.
this is the code:
What I need to do is perform this function for today date and the 14 days prior.
So what I am trying to do is get VBA to subtract a day by using:
When I run this though I get "Run-time error '70': Permission Denied
How can I get the date to subtract?
thanks,
this is the code:
Code:
Dim lDate As String
Dim lMonth As String
Dim lDay As String
Dim lYear As String
lDate = Date
lMonth = Format(Date, "mm")
lDay = Format(Date, "dd")
lYear = Format(Date, "yy")
lweekday = Weekday(Date, vbMonday)
What I need to do is perform this function for today date and the 14 days prior.
So what I am trying to do is get VBA to subtract a day by using:
Code:
Date = DateAdd("d", -1, Date)
lDate = Date
lMonth = Format(Date, "mm")
lDay = Format(Date, "dd")
lYear = Format(Date, "yy")
lweekday = Weekday(Date, vbMonday)
When I run this though I get "Run-time error '70': Permission Denied
How can I get the date to subtract?
thanks,