+ Reply to Thread
Results 1 to 102 of 102

code to get selected data from different files to one workbook

  1. #1
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    code to get selected data from different files to one workbook

    Hello experts,
    This is my second stage of the project. There are multiple files in a folder. Each file has multiple sheets of data of which the required sheets are only 2 of them namely B2B abd B2B -CDNR. I have a working sheet in a different location. I want the code to extract selected rows of data from each file and paste it in the working file (Destination folder) with just one condition. When the code extracts the selected rows data from B2B-CDNR sheet, if any, in the sheet then the figures of that sheet should be negative figures in the destination sheet. I have created a table of plan how to get the extract as suggested by one of the members along with the expected result sheet. (2B Combined). In the module I have inserted a few lines to make it much easier. Hope someone understands my requirement and shares a full single code. As there are multiple sheets to extract from I am sharing only 3 sheets. The loop function will extract the data of the other sheets hopefully.
    Thank you in advance.
    Last edited by RAJESH SHAH; 09-13-2023 at 12:36 PM. Reason: #Solved by Marc L
    "There is nothing called problem, it's just absence of an idea to find*solution."
    ?I have not failed. I?ve just found 10,000 ways that won?t work.?
    ?Thomas Edison

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Hello,

    rather than a guessing challenge you must better elaborate your need step by step in order there is nothing to guess …

    A sample must read

  3. #3
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    That is very cool Marc L. Everything explained in just a few lines. Thanks man. Next time I will try to explain like that. My requirement explanation in the steps sheet is way to long. I hope there is someone who can follow the above steps and help me create the code. This time I have not shared any module. I can create a 2B Combined sheet if it doesn't exists but getting the filter data from the source sheet to the destination sheet one below the other of all the files in the address link would be very tough for me.
    There is one more difficult part. B2B can be copied as it is but B2B= CDNR columns you will have to avoid column D and get the amount values in negative figures.(columns F, J to N)
    Last edited by RAJESH SHAH; 09-09-2023 at 05:45 AM.

  4. #4
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Hey guys, I need to consolidate source data workbooks to my 'macro' MAIN.xlsb workbook :

    1. Create B2B Combined sheet in the destination workbook if not created.
    Headings to paste in the B2B combined sheet.
    2. Search for all source data workbooks in the address path mentioned in the destination workbook steps sheet cell A1.

    3. Open a source data workbook and copy data only so without the header row selected rows containing Rajesh India* in B2B sheet and paste to required columns
    Open B2B-CDNR worksheet in the source sheet and paste in B2B Combined data sheet to required columns with amount figures converted to negative.

    4. Close the source data workbook. Process the same for all other source data workbooks.

    5. in column W enter the state code which depends on the name of the source sheet (8th and 9th character in the file name)
    6. In column X combine the values of columns W, A , C and I.
    workbook and source sheets shared in post #1 along with the header titles to paste, look up array and converted state code array.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    2. Search for all source data workbooks in the address path mentioned in the destination workbook steps sheet cell A1.
    As cell A1 does not contain any workbook criteria and as we won't guess what is it …


    Quote Originally Posted by RAJESH SHAH View Post
    3. … copy data only containing Rajesh India* in B2B sheet and paste to required columns
    So the content limited to column B only ?
    What means exactly 'required columns' ?


    Quote Originally Posted by RAJESH SHAH View Post
    5. in column W enter the state code which depends on the name of the source sheet (8th and 9th character in the file name)
    As the source sheet name is B2B or B2B-CDNR …


    The worst as usual with your threads : the expected result sheet does not match exactly your source data workbooks attachment …

  6. #6
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    1. There are multiple files in a folder from where the data is to be extracted. The address link of that folder to be pasted in A1 Cell of the steps sheet. I have shared only 3 files in the thread. There can be any number of files in the folder from 1 to 25 all containing B2B and B2B-CDNR sheets along with other sheets in the same order.
    2.From the B2B and B2B-CDNR sheets I want to extract only rows which contain Rajesh India* in column B to the 2B Combined sheet.
    3. The multiple files in the folder from where the data is to be extracted contains 2 digits in the 8th and 9th character. They are the state codes which the code will match the numbers to the state code and print in column W of each file in the destination sheet after B2B and B2B-CDNR sheets data are combined from the first row to the last row.

  7. #7
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    If you download and copy the 3 files to a folder, you can paste the address link of the folder containing the files in cell A1. This way the code will check the address link open a file extract the required data and close it again. Then It will open the next file and so on......

  8. #8
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    The code will have these lines to convert the number to state code.
    Please Login or Register  to view this content.
    The code to create the 2B Combined sheet with headings is like this.
    Please Login or Register  to view this content.
    The rest of the code is not in my league to write.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    So without the expected answer to my question neither a correct result attachment then
    you must detail at least for each source data worksheet which columns to copy and where to paste them …

  10. #10
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Marc L. In the source book(Workings) the 2B Combined is the expected result.
    Last edited by RAJESH SHAH; 09-10-2023 at 11:21 AM.

  11. #11
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    From the B2B sheet (files folder) copy all the filtered (Rajesh India*) columns and from B2B-CDNR copy all but one column but in the same order as mentioned in the result sheet with negative figures. (columns F and I to N).

  12. #12
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Only the difference will be 2 additional columns in the destination sheet the values of which will be derived by the code (Column W and X).

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    In the source book(Workings) the 2B Combined is the expected result.
    So again why this expected result does very not match your source data workbooks attachment ?‼
    With such no sense result I won't waste my time … Like we have not to guess which column must be 'avoided' !

  14. #14
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    From B2B sheet all columns to be pasted to 2B combined in the same order. But from B2B-CDNR sheet columns A B C and D to be pasted in 2B combined sheet under A B C D and columns F to W to be pasted to columns E to V in the 2B combined sheet. From the B2B-CDNR sheet the columns G K L M N and O to be pasted in 2B combined sheet in negative figures. Please see that the dates format in column E and P are the same when pasted to destination sheet.

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    Please see that the dates format in column E and P are the same when pasted to destination sheet.
    Not explained in your initial post neither in your post #4 ! You must better elaborate …
    From both source worksheets or only from B2B-CDNR ?
    What is the expected result ?
    As again the exact result according to your source workbooks is still expected …


    Another confusing point :

    Quote Originally Posted by RAJESH SHAH View Post
    3. Open a source data workbook and copy data only so without the header row selected rows containing Rajesh India* in B2B sheet and paste to required columns
    Open B2B-CDNR worksheet in the source sheet and paste in B2B Combined data sheet to required columns with amount figures converted to negative.
    So it seems only B2B needs to be filtered on 'Rajesh India' so not B2B-CDNR

    but in another post you wrote

    Quote Originally Posted by RAJESH SHAH View Post
    2.From the B2B and B2B-CDNR sheets I want to extract only rows which contain Rajesh India* in column B to the 2B Combined sheet.
    clearly meaning both worksheets need to be filtered

    but as in a later post you wrote

    Quote Originally Posted by RAJESH SHAH View Post
    From the B2B sheet (files folder) copy all the filtered (Rajesh India*) columns and from B2B-CDNR copy all but one column but in the same order as mentioned in the result sheet with negative figures. (columns F and I to N).
    then again it seems only B2B needs to be filtered …


    If someone shares a VBA procedure but with a wrong guessing interpretation are you able to fit / modify the code yourself
    according to what you forgot / misexplained ?‼
    If not why don't you create at least a thread with a crystal clear elaboration of the need
    with nothing missing neither nothing to guess and far above all with an exact expected result according to the source data.

    If you again still continue to create such threads don't be surprised to not receive help anymore …


    Last point :

    Quote Originally Posted by RAJESH SHAH View Post
    1. Create B2B Combined sheet in the destination workbook if not created.
    Headings to paste in the B2B combined sheet.
    Why over complicating again ?!
    According to the workbook purpose why not starting from an already created result worksheet
    with the exact headers row rather than hardcoding them ?

    Maybe the day when you will create the initial post at the level of what any Excel forum expects for
    but
    as this part is already demonstrated in your threads
    so in case you well share what here I expect for
    then I will start only from the already created result worksheet which simplifies the VBA coding
    which will be an 'one shot' code …
    Last edited by Marc L; 09-11-2023 at 07:55 PM.

  16. #16
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Hello Marc. Thank you for taking interest in my query. I am sharing the expected result sheet which is in the working workbook again.
    1. When I press the button in the workings sheet which is this, the exact extracted data result should be 2B combined sheet.
    2. The result is extracted from both the sheets B2B and B2B-CDNR.
    3.The 2B combined sheet is created by the code with the extracted data.
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Still data not matching the source data attachment, missing answers : I can do nothing, I'm out, good luck …
    Last edited by Marc L; 09-12-2023 at 04:38 AM.

  18. #18
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Marc. I am so so sorry. I wrongly edited the data properly before sharing it. I have filtered the rows containing Rajesh India* in the source folders and also corrected the destination sheet result. Edited the workings sheet with the correct expected result.
    Last edited by RAJESH SHAH; 09-12-2023 at 07:01 AM.

  19. #19
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    As warned since post #5 …

  20. #20
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    My checking tool does not stop anymore on the first result data row but on another and reports for some 'missing data' …
    If there is no error in your last result attachment then I hope some helper may see the light.

  21. #21
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Doin it manually there is a possibilty of making mistakes. The destination sheet sheet contain all the rows containing Rajesh India* in all the source sheets. Once again I made one mistake in copying and pasting manually by adding Rajesh Industries in the destination result sheet. The result should have rows containing text Rajesh India* only.

  22. #22
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Now I have to review my posts in order to try to find out any answer …

    Like post #5 :

    Quote Originally Posted by Marc L View Post
    As cell A1 does not contain any workbook criteria and as we won't guess what is it
    So no criteria ? Always .xlsx ?

  23. #23
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    A1 is the address link where the 2B folders are available to extract from. All the folders have an xlsx extension and there are only those folders from which the data is to be extracted.

  24. #24
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    If it helps I have a similar code which extracts data from an address link and combines the data of all the files in the folder. The problem is the sheets are different in this code and it combines 4 sheets from each xlxs file wheras in this case the sheet names are different and only 2 sheets data is combined.

  25. #25
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    Please see that the dates format in column E and P are the same when pasted to destination sheet.
    Quote Originally Posted by Marc L View Post
    Not explained in your initial post neither in your post #4 !
    You must better elaborate
    From both source worksheets or only from B2B-CDNR ?
    Without what to do I can skip that part and let you do it yourself …

  26. #26
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    When extracting data from the source sheet to the destination sheet sometimes the data format changes from dd-mm-yyyy to mm-dd-yyyy. So, I mentioned to get the correct date format. In the result if the dates have not changed the format then it will be good or else I have to post again if I have a date issue.

  27. #27
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    How it is possible when copying data - rather than 'extracting' - as an Excel date stays a date versus a text stays a text
    and as all about Date versus Text is yet explained in your threads so nothing to do …
    Last edited by Marc L; 09-12-2023 at 12:04 PM.

  28. #28
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Quote Originally Posted by Marc L View Post
    Last point :

    Quote Originally Posted by RAJESH SHAH View Post
    1. Create B2B Combined sheet in the destination workbook if not created.
    Headings to paste in the B2B combined sheet.
    Why over complicating again ?!
    According to the workbook purpose
    why not starting from an already created result worksheet
    with the exact headers row rather than hardcoding them ?

    Maybe the day when you will create the initial post
    at the level of what any Excel forum expects for
    but
    as this part is already demonstrated in your threads
    so in case you well share what here I expect for
    then I will start only from the already created result worksheet
    which simplifies the VBA coding which will be an 'one shot' code …
    So do you copy, aggree ?

  29. #29
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    As you wish. If you want the 2B combined to be in the workbook and not created with the code, it will do unless I get the result correct.

  30. #30
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    So, I will have to create the 2B combined sheet with headings in advance and then run the code. Right ???

  31. #31
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Right as the VBA procedure must be located within the result worksheet module


    Quote Originally Posted by RAJESH SHAH View Post
    code to get selected data from different files to one workbook
    According to your thread title and according to your post #18 source data workbooks :
    does your 'selected' means in fact source data already filtered ?!
    In that case only the already filtered source data worksheets will be copied to the result worksheet ?
    Last edited by Marc L; 09-12-2023 at 12:26 PM.

  32. #32
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    No. The data was filtered by me to show you the rows to be extracted from them. All the files in the folder will have full data and will not be filtered. The code has to open each file, filter the data, select the rows with the criteria and paste them in the 2B combined sheet and finally close the file.

  33. #33
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Right as the VBA procedure must be located within the result worksheet module …

    Yes, The button will be in the steps sheet and the code module will be assigned to it.

  34. #34
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    The code has to open each file, filter the data, select the rows with the criteria and paste them in the 2B combined sheet and finally close the file.
    Ok that explains your confusing thread title - losing helpers again with such initial post not matching the title - as
    a good enough VBA procedure does not need to select anything to copy data …

    It seems now all lights are green so I will give it a try later but
    well note this is the last time with such thread title and such initial post.

  35. #35
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Phew!!! That is great. Now that you have understood the query, I will leave it to you now. See you tomorrow. Good Night.

  36. #36
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    The issue is not to understand but to read a good enough elaboration with nothing to guess and with a well reflecting attachment …

  37. #37
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool An one shot code so my first and last try ...


    According to the initial post attachment

    • once satisfied with my VBA demonstration you should remove the useless module you have renamed.

    • Sheet2 is used to lookup the States Codes - nothing hardcoded - and its column F lists any non matching rejected workbook.

    • A starter VBA demonstration to paste only to Sheet3 (2B Combined) worksheet module :
    Please Login or Register  to view this content.
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 09-14-2023 at 06:38 AM. Reason: VLOOKUP correction ...

  38. #38
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: An one shot code so my first and last try ...

    @Marc: Trying to understand your code (nearly there) , this statement gave an "error" - wrong random value

    Please Login or Register  to view this content.


    -
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  39. #39
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    As I post only tested working VBA procedures so :

    • your Excel or your Windows is somewhere : to close or to reboot …

    • You felt into the bad reader trap !
      So just restart first only from the initial post attachment, upload it then
      well read and apply at least post #37 direction (ask if you do not understand it) …

  40. #40
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    @Marc: Running from the file posted in post #1 still gives the error.

    And as for "bad reader trap": as it took 30 posts for you to understand the requirement, you are in no position to criticise others: and yes, I did post the code in the sheet module as INSTRUCTED.

  41. #41
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: An one shot code so my first and last try ...


    Quote Originally Posted by JohnTopley View Post
    this statement gave an "error" - wrong random value
    I never met this message, weird according to the involved codeline,
    nothing 'random' as it's only about the number of used rows within the host (Sheet3) …
    Tested without any issue under 2010 version, like yours ?

  42. #42
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by JohnTopley View Post
    And as for "bad reader trap": as it took 30 posts for you to understand the requirement, you are in no position to criticise others
    Not any criticism but the classic issue.
    I did not need 30 posts to understand,
    RAJESH needs again some posts to just well explain what should be done in the initial post.
    But according to your comment if you are such clever why you did not help ? …

  43. #43
    Forum Contributor
    Join Date
    07-24-2023
    Location
    Como, Italy
    MS-Off Ver
    MSO 365 - Ver 2208
    Posts
    120

    Re: code to get selected data from different files to one workbook

    Good morning everyone,

    I tried following the instructions:
    • I took the original files from post #1;
    • I inserted the code proposed in post #37 with the changes;
    • I changed the contents of cell "A1" in the "Steps" sheet to the path where I saved the files;
    and everything worked correctly on my pc.

    Bye
    Max
    let's compare ideas

  44. #44
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Another classic case : desactivate any add-in, close Excel, …

  45. #45
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Tested after a restart with original file and still the same issue: USEDRANGE is known to be "vunerable" to errors but I accept it might be my Excel 2010,

    My own "VBA for Dummies" version runs without any problem so i'll stick to the "KISS" VBA I use!

    And I see little merit in putting code in the worksheet vs standard module - what are the advantages, if any ?.

  46. #46
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: code to get selected data from different files to one workbook


    Quote Originally Posted by maxpit View Post
    I inserted the code proposed in post #37 with the changes;

    and everything worked correctly on my pc.
    Grazie Max !

    But I'm not sure what exactly means « with the changes » ?

  47. #47
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Just to clarify: it was the FIRST "R" that was incorrect: all others were OK and finally results were totally correct so my m/c or Excel "glitch". QED.

  48. #48
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by JohnTopley View Post
    USEDRANGE is known to be "vunerable" to errors
    In fact in the old time with previous versions than 2010,
    with not smart worksheets (in this case you can use CurrentRegion rather)
    but not from an almost empty worksheet like here …


    Quote Originally Posted by JohnTopley View Post
    And I see little merit in putting code in the worksheet vs standard module - what are the advantages, if any ?.
    Better, Easier, Safer, Stronger

    In a class module any unqualified object or property belongs to the host …
    A proof of the good health of the Excel version.

  49. #49
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by JohnTopley View Post
    and finally results were totally correct so my m/c or Excel "glitch". QED.
    If it's not the classic Excel / Windows RAM issue - the reason why never use Excel for pro database project - see post #44 …

  50. #50
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Another view .....

    As a general rule, the sheet modules and the ThisWorkbook module should contain only event procedures, and nothing else. All other code should reside in regular code modules. Some would argue convincingly that private procedures used only by the event procedures in a module should be contained in the same sheet/thisworkbook module in which they are used. There is no practical limit to the number of modules allowed in a project, so you should organize your code into multiple modules, based on the type of functionality provided by the code.

    Cordially, Chip Pearson Microsoft MVP, Excel Pearson Software Consulting, LLC www.cpearson.com
    Cordially,
    Chip Pearson
    Excel MVP 1998 - 2014
    Pearson Software Consulting, LLC
    www.cpearson.com

  51. #51
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Yes another POV, like using useless object variables, Worksheet like Workbook
    even if already exist CodeNames, ActiveSheet, ActiveWorkbook & ThisWorkbook …

  52. #52
    Forum Contributor
    Join Date
    07-24-2023
    Location
    Como, Italy
    MS-Off Ver
    MSO 365 - Ver 2208
    Posts
    120

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by Marc L View Post

    Grazie Max !

    But I'm not sure what exactly means « with the changes » ?
    Excusez-moi, ... by the word changes I meant applying your three tips.

  53. #53
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    As far I can judge from the VBA posts I have viewed , you are the only VBA coder who uses worksheet code in this way - which does not make you wrong .....

    As you another POV ...so let's leave it at that.

  54. #54
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: code to get selected data from different files to one workbook


    Quote Originally Posted by maxpit View Post
    Excusez-moi, ... by the word changes I meant applying your three tips.
    Tutti va bene, no apologies required, as sometimes I may be dumb like anyone, can misread or misunderstand …

  55. #55
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by JohnTopley View Post
    you are the only VBA coder who uses worksheet code in this way - which does not make you wrong ...
    In fact I'm very not the only one, ok pretty rare on beginners forums, but I've learned also with pro coders …
    Even if I did not see, understand at the moment what & why,
    sometimes several years after facing some terrible issue I remember some advises
    and applying theirs tips / tricks I had to admit such issue can never occur.

    As a reminder when creating a button for example on a worksheet and when allocating the VBA procedure
    sometimes this is automatically pointed to the worksheet class module which is so logic
    in case a worksheet must be copied / moved with its objects and relative VBA procedures at once,
    so yes a 'general rule' is nothing but a general rule which is not always the way to go …

    As a reminder - as yet explained in another thread - I like to use worksheets CodeNames but, when
    the workbook attachment does not contain any code, local Excel versions - like mines - transform the original standard CodeName
    like Sheet1 to my Excel local version standard CodeName as Feuil1
    the reason why sometimes I move to the worksheet class module : ♪ Better, Easier, Safer, Stronger ♫ …

  56. #56
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Marc. As discussed earlier, I have inserted the 2B Combined sheet manually in the destination workbook. I assigned your macro to the button in the steps sheet. I pasted the link address of the source files in cell A1. When I play the code I got an error 424. Did I miss anything which I am not aware of.
    Object required error at this line UsedRange.Offset(1).Clear

  57. #57
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    I think I have missed something to understand. I inserted the code is sheet3 as suggested. When I run the code it is running without any error, but, the result sheet is empty.
    Last edited by RAJESH SHAH; 09-13-2023 at 09:07 AM.

  58. #58
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Did you put Marc's code in the "2B Combined" worksheet ?

  59. #59
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Yes. John Topley. At first I inserted it in a module. But later when I read the post of Marc I noticed that he had asked to put his code in the 2B combined worksheet. Now I am not getting any data in the 2B Combined sheet at all even when the code has run without any error.

  60. #60
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Look to see if data starts at a lower row e.g 42 as I had a problem that the code did not place the results from row 2 as expected.

  61. #61
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    I think I missed something which I am not aware of. If maxpit could get it right that means I have missed something.

  62. #62
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by JohnTopley View Post
    Look to see if data starts at a lower row e.g 42 as I had a problem that the code did not place the results from row 2 as expected.
    Which data source or destination ? The source data all the sheets start from the 7th row and destination sheet where the data is to be extracted in row2.

  63. #63
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Look at "2B Combined"and just scroll down

  64. #64
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    The whole sheet is blank except for the headings.

  65. #65
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Are you sure you selecting the right version of the code ? delete the code from the "module" if it is still present, close Excel and restart Excel.

    and/or shut down your computer, reboot and then open Excel.
    Last edited by JohnTopley; 09-13-2023 at 09:30 AM.

  66. #66
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Or .... try this... change code to

    ..
    Please Login or Register  to view this content.

  67. #67
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    John Topley. Are you getting any result in the 2B Combined sheet.? I deleted the code from the module, closed excel and restarted the computer. I once again opened and pasted the code in the 2B Combined sheet and still I am not getting any result in the 2B combined sheet.

  68. #68
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by JohnTopley View Post
    Or .... try this... change code to

    ..
    Please Login or Register  to view this content.
    After replacing with the above line too, I am not getting any result.

  69. #69
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    See post #66 and apply this code. I get results in all cases BUT with the code change, they start correctly at row 2 in "2B Combined".

  70. #70
    Forum Contributor
    Join Date
    07-24-2023
    Location
    Como, Italy
    MS-Off Ver
    MSO 365 - Ver 2208
    Posts
    120

    Re: code to get selected data from different files to one workbook

    Hi RAJESH SHAH,

    did you enter the path of the files to be imported into A1 of the Steps sheet?

  71. #71
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Maxpit. Of course Yes. I did that.

  72. #72
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    I played the code using F8 and I think this line has to paste the data of a selected sheet which it is not posting the data. F = Dir$

  73. #73
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    The attached has results running Marc's macro with my minor change. I have'nt a clue why it does not work.

    Use F8 and stepping through the code should identify the issue.
    Attached Files Attached Files

  74. #74
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    After deleting the data in 2B combined data in your workbook and changing the address link, I played the code and it is displaying only the headings in the destination sheet.

  75. #75
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Please Login or Register  to view this content.
    should show the next file to be processed so if files are 02,06.07 (state codes) it will show 06 then 07 Xlsx Files

  76. #76
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    It is finding the files going to the designated sheets closing the file and everything is fine. But no data is copied to 2B Combined sheet.

  77. #77
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Then there is somthing radically wrong in what you are doing as I have run Marc's code numerous times without a problem.

    In w/book I posted try running "Create2BCombinedSheet" macro.

  78. #78
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    As I already said I am missing something. Once again I Will try again from the start and check and revert back.

  79. #79
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    No idea why it is not displaying the result in 2B Combined sheet. I downloaded the file from Post #1 and retested that file too. But the code runs without any error but no result.

  80. #80
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    PHEW!!! Finally got it right. My Bad. I was checking with the original data and I didn't replace the criteria *"RAJESH INDIA*".
    Thank you Marc L. I really appreciate your unconditional support. Thanks man.

  81. #81
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    One thing I have to keep in my mind is that the steps sheet should always be sheet1 and State code should be sheet2. No matter what ever the 2B combined sheet is the code will work. Right Marc L..

  82. #82
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    This is the beginning of a new project and I have already created 3 modules earlier. How will I call this module as the code is inserted in a sheet.? If you can please replace the sheet1 and sheet2 with actual sheet names so that I can insert the code in a module and call it along with other modules without any issue. There are at least 20+ more modules to create in the whole project and this is just the 4th module. If you could convert the code compatible to play in a module I would not have a problem in future.

  83. #83
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Do you mean ...

    Please Login or Register  to view this content.
    Macrox are your "other" macros

    Demo1 has to be defined as
    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.
    so macro "MAIN" is the one which calls ALL your other macros
    Last edited by JohnTopley; 09-13-2023 at 03:05 PM.

  84. #84
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    PHEW!!! Finally got it right. My Bad.
    Well, well, well, as written in post #37 :

    Quote Originally Posted by Marc L View Post
    According to the initial post attachment
    So including obviously source data workbooks attachment …
    Hoping you well understood why it's better to not harcode such criteria like yet demonstrated in your threads.


    Quote Originally Posted by RAJESH SHAH View Post
    If you can please replace the sheet1 and sheet2 with actual sheet names
    Worst idea ‼ Rename any worksheet and code fails !
    As using their CodeNames like Sheet1 even if any worksheet is renamed the VBA procedure still works !

    But as a starter VBA procedure you are free to modify it as per your will …

  85. #85
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Marc L. The code is super. I had 10 files with me to test and it took about 15 seconds to extract the required data from them. 25 files will take around less than a minute to extract from. I went through the code and try to understand it using F8. I need 2 things to understand from the code.
    1. why are these lines added I have no idea. ?
    Please Login or Register  to view this content.

    2. Which line in the code is extracting the values for column X.?
    Please Login or Register  to view this content.
    [/CODE][/CODE]

    I hope it will not be a problem if I call the 3 modules in the beginning of the code and the rest of the modules at the end of the code. That time will say when I have created the last module in the project. (As suggested by John Topley)

  86. #86
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by Marc L View Post

    Well, well, well, as written in post #37 :
    Yes post #37 is perfect.

  87. #87
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by JohnTopley View Post
    Do you mean ...

    Please Login or Register  to view this content.
    Macrox are your "other" macros

    Demo1 has to be defined as
    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.
    so macro "MAIN" is the one which calls ALL your other macros
    Thanks John Topley. I will try out once this is completed.

  88. #88
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    PLEASE do NOT put unnecessary quotes in your replies: they are clutter and not required.

  89. #89
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    it took about 15 seconds to extract the required data from them
    Do not expect some speed with such basic coding when opening workbooks to copy data
    but this is the easy procedure to maintain …

    Without opening any workbook under Excel there is the fast ActiveX ADODB way
    but harder to maintain, loosing the cells formatting, I can't remember if demonstrated in your threads.
    I did not go that way 'cause of your initial post such confusing …
    Not sure to have the time to give it a try the next days
    and as since a week I met some difficulty to reach this site, no issue with others,
    so the reasons why I can be offline for a while …


    Quote Originally Posted by RAJESH SHAH View Post
    1. why are these lines added I have no idea. ?
    For the first codeline it is already explained within post #37 …

    For the second codeline that should be obvious but, in order to well understand, once you have launched the procedure
    and you get data in result worksheet, see the number of used rows then put this codeline entirely in comment
    then launch again the VBA procedure and see where is the last used row …


    Quote Originally Posted by RAJESH SHAH View Post
    2. Which line in the code is extracting the values for column X.?
    Obviously the codeline with Range("X

  90. #90
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: code to get selected data from different files to one workbook


    There is a glitch in post #37 code, correction in progress …
    Last edited by Marc L; 09-14-2023 at 06:12 AM.

  91. #91
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Post #37 one shot VBA procedure edited …


    Quote Originally Posted by Marc L View Post
    For the first codeline it is already explained within post #37 …
    So RAJESH, only once you have pasted the post #37 corrected version, to well understand
    into the source data workbooks folder add a workbook not matching any Sheet2 state code like '99'
    then launch the VBA procedure, see what happens like yet explained within post #37 …

  92. #92
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    The speed is very good. It is faster than my expectation.
    Sorry, I wanted to ask about the column W and not X. Which line prints the value in column W ? (The one which is printing the Location state code).

  93. #93
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    This one

    Please Login or Register  to view this content.
    given

    Please Login or Register  to view this content.
    is the State

    obviously cannot work out that column W is column 23

  94. #94
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Okies. Now I understood it. Thanks John Topley.

  95. #95
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    But still trying to understand this line where it clears the data of columns F and the following columns in the State code sheet. Is it needed ..??
    Please Login or Register  to view this content.
    .

  96. #96
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: code to get selected data from different files to one workbook


    Quote Originally Posted by RAJESH SHAH View Post
    Is it needed ..??
    Following posts #89 & 91 should give you the obvious answer …

  97. #97
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Quote Originally Posted by Marc L View Post

    There is a glitch in post #37 code, correction in progress …
    What glitch..????

  98. #98
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    Did you actually look at post #37 ? Perhaps code highlighted in RED

  99. #99
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: code to get selected data from different files to one workbook


    (removed / Thanks John again)

  100. #100
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    Post #37 is perfect. I am already using it without any issues.

  101. #101
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: code to get selected data from different files to one workbook

    with the change ? If not, I recommend you add the change.

  102. #102
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: code to get selected data from different files to one workbook

    I checked and compared the code in post #37 and I have rightly used the edited Post #37. Thanks for the recommendation.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 03-28-2022, 09:29 PM
  2. Replies: 3
    Last Post: 06-28-2020, 09:05 AM
  3. [SOLVED] Consolidation of data From Different Files to one Master workbook, Code Error.
    By structo in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2016, 03:29 PM
  4. [SOLVED] VBA - Excel code to copy and paste from several Sharepoint workbook files to one workbook
    By TraceyPatterson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2015, 06:45 AM
  5. code to take last saved workbook and hypelink it to selected cell
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2014, 02:13 AM
  6. [SOLVED] Copy selected files sheets to the this workbook
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 02:21 PM
  7. Loop through data on a workbook, selected it and paste in current workbook
    By concatch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-11-2012, 08:59 AM

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