PDA

View Full Version : VBA-Import text file of yesterday's date which is the file name



Joseppo
03-23-2021, 03:54 AM
I am new in Excel VBA and macros and I am facing some difficulties in coding. I am working in a daily data that are placed in a folder everyday, I need a code to import the file of yesterday's date whenever I run the macro. Any suggestions?

SamT
03-23-2021, 08:49 AM
Dim YesterdayName as string
YesterdayName = Format(Date-1, "FormatString") & ".xlsm"

It takes a bit more code if you skip Weekends/Holidays and such