Question about date in macro

Hi guys;

I record a macro which contains the follwoing code:

Workbooks.Open Filename:="J:\MVS\Data\20130605\20130605-1008-je.xls"

Everyday, one folder called "YYYYMMDD" (today's date)and one file called "YYYYMMDD" (today's date)-1008-je.xls is created in our LAN. I want to make a change in the code so that the macro will pick up the new date automatically. For example, the macro will open the file J:\MVS\Data\20130606\20130606-1008-je.xls on the next day.

I appreciate your help in advance

Chris

Nick's picture

dim TodaysDate as

dim TodaysDate as string
TodaysDate = format(date,"yyyymmdd")
Workbooks.Open Filename:="J:\MVS\Data\" & TodaysDate & "\" & TodaysDate &"-1008-je.xls"

Nick

Thank you so much. It really

Thank you so much. It really works very well.

I found that Macro is very powerful in my work, but I only can faciliate some easy steps in excel process by recording a macro. I've tried to read and understand the code behind, but it is hard for me.

So can you recommend some books or materials related to excel macro?

Chris

Nick's picture

start here ! Everything from

start here !
Everything from basic to advanced..

http://excelexperts.com/Free-VBA-Training-Videos

book to learn the first steps in excel macro

excel vba for dummies! it is amazing! I am learning from it since last month and I could be more satisfied :)