+ Reply to Thread
Results 1 to 7 of 7

Macro to open files with diffrent date format

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    Mumabi
    MS-Off Ver
    Excel 2003
    Posts
    17

    Macro to open files with diffrent date format

    Hi All,

    Every month i have to create report using 5 diffrent files where file name remain same but only date format change.Files names are in below format

    1) IND_abc_MAPPING20130502 (date format is YYYY-MM-DD)
    2) IND_abc_TABLE20130502 and so on

    so far code is working perfect where code ask user to select path from where he has to select files but i am stuck after that (code highlted in red) after opening all 5 files i have activate particular file and have to copy data from respective file for eg. after opening all 5 files first i have to activate 3rd file nd copy data then 5th file and so on and my problem is that every month file name will change for eg this month file name would be "IND_abc_MAPPING20130502" Next month it will be 20130602 and so on. so i need a code so that macro will activate open file using any particular word of file name because every month file name will be same only date will change.


    Please Login or Register  to view this content.


    Dorry for any confusion. do let me know if you need any more clarification from my side.

    Thanks in advance !!!

    Suyog patil

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro to open files with diffrent date format

    Your example code is prompting to select a file and not a folder as it uses the msoFileDialogFilePicker dialog.

    When you open the file, you are assigning it to a variable. You can use that variable later in the code to reference that specific workbook regardless of its filename. Use a different variable for each file you open e.g;
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-28-2013
    Location
    Mumabi
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro to open files with diffrent date format

    Hi,

    first of all Thanks for your quick reply. I am having one doubt code which i provided I am using that code 5 times to open 5 diffrent files because of diffrent msgbox every time. so after running this code 5 times i entered your code but that code is activating only last file. as you said i have to declare diffrent variable for each file so use "WC" instead of "WB" but it says object required..so any solution actually i am very new to VBA ....

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro to open files with diffrent date format

    Quote Originally Posted by suyogpatil View Post
    Hi,

    first of all Thanks for your quick reply. I am having one doubt code which i provided I am using that code 5 times to open 5 diffrent files because of diffrent msgbox every time. so after running this code 5 times i entered your code but that code is activating only last file. as you said i have to declare diffrent variable for each file so use "WC" instead of "WB" but it says object required..so any solution actually i am very new to VBA ....
    Show your code with the five different file opens.

  5. #5
    Registered User
    Join Date
    05-28-2013
    Location
    Mumabi
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro to open files with diffrent date format

    Hi please find attached file contains code which you required its my first time i am creating this so may be code is not that much perfect
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro to open files with diffrent date format

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-28-2013
    Location
    Mumabi
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: Macro to open files with diffrent date format

    Wohhh perfect exactly what i want .. this code is just more than perfect... really a big thanks for quick reply and taking time to solve my problem...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1