rmobley232
New Member
- Joined
- Jun 30, 2016
- Messages
- 15
I am trying to write a code to import a text file on a daily basis that will have the previous and current yyyymmdd the title of the file. Here is the code when I recorded the macro:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\br4rkm\Desktop\RI_Maint_20190318_20190319.txt", Destination:= _
Range("$A$2"))
.Name = "RI_Maint_20190318_20190319"
Here is how I am attempting to update the code, not having a lot of luck. Thanks so much for the assistance:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\br4rkm\Desktop\RI_Maint_" & (Format(Now(), "yyyymmdd")-1)"_ & " & Format(Now(), "yyyymmdd") & ".txt", Destination:= _
Range("$A$2"))
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\br4rkm\Desktop\RI_Maint_20190318_20190319.txt", Destination:= _
Range("$A$2"))
.Name = "RI_Maint_20190318_20190319"
Here is how I am attempting to update the code, not having a lot of luck. Thanks so much for the assistance:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\br4rkm\Desktop\RI_Maint_" & (Format(Now(), "yyyymmdd")-1)"_ & " & Format(Now(), "yyyymmdd") & ".txt", Destination:= _
Range("$A$2"))