using a dialog box to select the file for consolidation

  • hello all,


    the following is my code that matches header between two workbooks and copies the data.




    as you can see the file path of the second file must be set evertime i want to work with a different file. People keep tampering with the code by accident so i want to eliminate this way and chose the dialog box option. global headcount is what i want to select using a dialog box, RMG dashboard is my file with dashboard worksheet


    i have something like the following to start but it is incomplete.. any help?


  • Re: using a dialog box to select the file for consolidation


    i have used a similar exam to arrive at the below code it maybe wrong



    i get a compile error duplicate declaration in the current scope on this line
    Dim wbk As Workbook ' use this variable to reference the workbook we're opening

  • Re: using a dialog box to select the file for consolidation


    Try

  • Re: using a dialog box to select the file for consolidation


    woah jindon, a little explanation please what does this do.....
    can u provide comments so i ca understand... thank you

  • Re: using a dialog box to select the file for consolidation


    please give me two minutes i have to type this out...


    but is my understanding correct that after opening it copies data between workbooks based on their headers

  • Re: using a dialog box to select the file for consolidation


    the dialog box opens and after selecting the file i get an runtime error on fn = "'" line error 438 object does not support this property of method

  • Re: using a dialog box to select the file for consolidation


    the code is the same...
    my dashboard's sheet name is dashboard is that the reason of the problem?

  • Re: using a dialog box to select the file for consolidation


    yea dude the sent over also worked......


    let me explain the situation with the actual data...


    my file is dashbboard the sheet is also dashboard..
    the file i want to copy from is g headcount with the sheet headcount....



    as i understand the situation i changed this workbook.sheets("dashboard")....
    since i am opening the other file through the dialog box the name would not be a problem....


    now what happens is the dialog box opens i am able to select the file.. it runs but does not copy

  • Re: using a dialog box to select the file for consolidation


    I'm talking about this "sheet1"



    fn = "'" & Left$(fn, InStrRev(fn, Application.PathSeparator)) & _
    "[" & Mid$(fn, InStrRev(fn, Application.PathSeparator) + 1) & "]sheet1'!"

  • Re: using a dialog box to select the file for consolidation


    did a quick change and it gives me a subscript out of range on the with this workbook line

  • Re: using a dialog box to select the file for consolidation


    As I don't know the sheet name(s), all I can do is making the code to work with the files you uploaded.



    There's no magical code that can read your brain.


    No idea about sheet name(s), data structure, etc.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!