Hello,
I am trying to pull data from a file that is live updating as it is used, but the file saves as a new name every 24 hours. How do I write in a name to open that allows the macro I have to continue pulling data but pull from the data for the current date?
For reference, every time a machine is run it produces and saves one line of results onto an existing .csv file. This file is named with the day and machine name, so it looks something like "20151130_MachineName.csv" This would be an example of today's file. Tomorrow (December 1st) would have a file name "20151201_MachineName.csv" I want my macro to always be pulling from the file from the current day.
My code works for pulling an individual day right now, but I have to manually change it to the new day. Here's what I've got:
Any help would be greatly appreciated. Thanks!
I am trying to pull data from a file that is live updating as it is used, but the file saves as a new name every 24 hours. How do I write in a name to open that allows the macro I have to continue pulling data but pull from the data for the current date?
For reference, every time a machine is run it produces and saves one line of results onto an existing .csv file. This file is named with the day and machine name, so it looks something like "20151130_MachineName.csv" This would be an example of today's file. Tomorrow (December 1st) would have a file name "20151201_MachineName.csv" I want my macro to always be pulling from the file from the current day.
My code works for pulling an individual day right now, but I have to manually change it to the new day. Here's what I've got:
Code:
Sub Get_Data() Application.Worksheets("Data").Unprotect
Workbooks.OpenText FileName:="K:\Keyence\20151130IM_MachineName.csv", _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True, _
Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Range("A1:X255").Select
Selection.Copy
ThisWorkbook.Activate
Sheets("Data").Select
Range("A1").Select
ActiveSheet.Paste
Any help would be greatly appreciated. Thanks!