+ Reply to Thread
Results 1 to 7 of 7

Vba to copy worksheets from different folders into a new workbook based on sheet name

  1. #1
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    38

    Vba to copy worksheets from different folders into a new workbook based on sheet name

    Hi,

    Firstly, I am explaining the data I have and what I intend to do with it.

    I have 2 folders - Sent and Received and each folders have multiple workbooks.

    For Example - In Sent file, I have a workbook with name 'Peter' and in Received file, I have a workbook with name 'Peter-R' (R refers to received)
    so.. each file that I have sent will come back with the suffix R, which I save in Received folder.

    I have a new workbook named 'Compare' outside of these 2 folders where I have list of all the Workbook names that are in Sent Folder. Now I had recorded a Macro as below to copy both sheets into a new workbook but, the problem with this code is that it takes the cell value instead of Range. Each time I have to change the names inside the macro.

    Can someone help me in copying sheets from both sent and received folders (based on the file names in column A of compare workbook) into a new workbook and rename it as 'Peter-compare' and save it in a new folder named Comparison. (I will create this new Folder - Comparison).

    Hope this is not confusing!

    Please Login or Register  to view this content.
    Last edited by Kinjal Doshi; 12-14-2020 at 08:11 AM.

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

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    38

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Hi Alpha,

    Thank you so much.. this is perfect.
    I need one more help... I had below VBA that would compare the difference between the the two files as below
    Is it possible for you to add this vba that it compares and highlights the difference and then save the file in comparison folder?

    I am sorry... I didn't give this requirement earlier... Please help!

    Please Login or Register  to view this content.

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

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    38

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Hi Alpha,

    I tried this out.. but it is not highlighting the differences. It is highlighting other columns.

    Can you add your code instead of this? I want it to highlight the differences in Received Sheet. Comparison of rows begins with Row 5 and instead of changing the background cell color, I want it to change the font color to Red.

    Awaiting your soonest reply
    Last edited by Kinjal Doshi; 12-16-2020 at 01:15 AM.

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

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Why did you give me that code to incorporate if it doesn't work? And it doesn't start at row 5. And it doesn't change font color.

    You can use Conditional Formatting to highlight the differences..
    https://www.extendoffice.com/documen...sheets.html#a4

  7. #7
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2016
    Posts
    38

    Re: Vba to copy worksheets from different folders into a new workbook based on sheet name

    Hi Alpha,

    Sorry.. there was a silly error on my end... My entire column was replaced.. due to which this macro wasn't working.
    It is working perfectly now.. really sorry for all the trouble caused and thanks a ton!
    Last edited by Kinjal Doshi; 12-16-2020 at 02:53 AM.

+ 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. [SOLVED] Copy several sheet from workbook into separate files and save into seperate folders
    By Wuzzyoisseau in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-10-2020, 09:18 PM
  2. [SOLVED] Copy sheet from another workbook based on ComboBox names of the Workbook and sheet
    By igormigor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2016, 10:07 AM
  3. Replies: 0
    Last Post: 05-26-2015, 04:31 PM
  4. Copy worksheets to new workbook based on cell value criteria....please help!
    By radioactivity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2015, 02:26 AM
  5. saving several worksheets in single workbook in several folders
    By isurunk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2014, 07:09 AM
  6. Copy two worksheets in new workbook where one sheet is constant
    By jo.chi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 08:44 PM
  7. Replies: 0
    Last Post: 12-04-2012, 01:01 PM

Tags for this Thread

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