Hi,
I have found some answers to somewhat similar questions but none that fits my need and unfortunately I am not experienced enough with VBA to piece together a functioning macro from what I've found searching online so far.
What I need to do is to create a macro that runs automatically once per day. I know how to use the Workbook.open function or a button but I'd rather have the macro run on a timer if possible. If that's not possible (which I'm thinking is probably the case), I'll run it when the workbook opens. Here's what I need the macro to do:
I need the macro in my workbook to go to a remote server directory, look for the latest file by the date in the name of the file (e.g. "MyDataFile_01-01-2014.csv"), there will be many files, same name but different dates in the directory. Once the file with the latest date is identified, I need to copy the data from "sheet 1", then look in my workbook for a worksheet named "MyDataFile"(without the date appended), find the last used row in the only table in this worksheet (lets say it's named "Table1"), whether this is row 2 (below the header) or row 2000, and append the copied data to this table.
Ideally, I'd like to have a message pop up if I have to run the macro on opening the workbook, stating that the latest data is being retrieved AND I would love it if the macro could "know" it the latest file has already been retrieved so I don't duplicate data - since I am appending the data to the bottom of a table - and if the latest available data is already in the workbook, a message stating this would be great as well. Generous commenting would also be appreciated since I am trying to learn how to do this myself.
This is a tall order (for me anyway) if anyone knows how to do this I would be elated because so far I am striking out on this one.
Thank you beforehand to anyone who can help me out.
G
I have found some answers to somewhat similar questions but none that fits my need and unfortunately I am not experienced enough with VBA to piece together a functioning macro from what I've found searching online so far.
What I need to do is to create a macro that runs automatically once per day. I know how to use the Workbook.open function or a button but I'd rather have the macro run on a timer if possible. If that's not possible (which I'm thinking is probably the case), I'll run it when the workbook opens. Here's what I need the macro to do:
I need the macro in my workbook to go to a remote server directory, look for the latest file by the date in the name of the file (e.g. "MyDataFile_01-01-2014.csv"), there will be many files, same name but different dates in the directory. Once the file with the latest date is identified, I need to copy the data from "sheet 1", then look in my workbook for a worksheet named "MyDataFile"(without the date appended), find the last used row in the only table in this worksheet (lets say it's named "Table1"), whether this is row 2 (below the header) or row 2000, and append the copied data to this table.
Ideally, I'd like to have a message pop up if I have to run the macro on opening the workbook, stating that the latest data is being retrieved AND I would love it if the macro could "know" it the latest file has already been retrieved so I don't duplicate data - since I am appending the data to the bottom of a table - and if the latest available data is already in the workbook, a message stating this would be great as well. Generous commenting would also be appreciated since I am trying to learn how to do this myself.
This is a tall order (for me anyway) if anyone knows how to do this I would be elated because so far I am striking out on this one.
Thank you beforehand to anyone who can help me out.
G