+ Reply to Thread
Results 1 to 7 of 7

VBA or Macro to merge two worksheets into one

  1. #1
    Registered User
    Join Date
    04-20-2014
    Location
    Derby
    MS-Off Ver
    Excel 2010
    Posts
    59

    VBA or Macro to merge two worksheets into one

    Good Afternoon,

    I am trying to find a way to merge two worksheets into one, and sort on a particular column.

    the work sheets that need to be merged are NottsUp, & NottsDN I am trying to put them into NOTTU&D, the column that I am trying to sort by is called Nottingham Dep, this will give me trains leaving Nottingham in time order from 0001 through to 2359. in both the up and down direction.

    I have tried to use put one set of data below the other and use the sort function, but this doesn't work, as I get times in wrong columns, there is also a column on each sheet that aren't common to both sheets.

    I appreciate that this is a big ask, and what seems to me almost imposable, but I am sure that it must be possible, and no doubt easy if you know how, this would be a big help if solution could be found.

    I have attached the workbook in question - many thanks in anticipation.

    regards

    Deek
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA or Macro to merge two worksheets into one

    Deek,
    You can add the unique headers from each sheet in to sheet NottU&D, then merge the data from both sheets. The sort bit of code I have does not work as the column is mixed with numbers and text so, I used a recorded macro.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-20-2014
    Location
    Derby
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: VBA or Macro to merge two worksheets into one

    Good Morning AB33,

    Thank you for your reply and the time you have taken to look at this problem, just a couple of questions, I had an error message when I tried to open the file captupe1, when I enabled content I had the message in capture 2, I also noticed that there was some code commented out, capture 3.

    I deleted all the contents in "NottU&D" and rerun the macro, I get an error message capture 4, and capture 5, if I uncomment the code it seems to run (or at least thinks about running) but then comes up with the error message capture 6 & 7. I also noticed that in the spreadsheet that I down loaded the first column A1 from either sheet hadn't been merged.

    I have also imported the module into another spread sheet, and with all code un-commented it does run, but pulls all the data into column A of the NottU&D sheet

    Is there something that I have done wrong, or is it the good old Microsoft misbehaving. would you please be able to have another look at this - many thanks in anticipation.

    DeeK
    Attached Files Attached Files
    Last edited by deek; 05-29-2016 at 03:33 AM.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA or Macro to merge two worksheets into one

    I can not test the code on a picture, please attach excel book.

  5. #5
    Registered User
    Join Date
    04-20-2014
    Location
    Derby
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: VBA or Macro to merge two worksheets into one

    apologies, please find the excel book attached.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA or Macro to merge two worksheets into one

    There are no headers on sheet NottU&D, hence the code does nothing. The code works by matching the unique columns on row-1 in sheet NottU&D with the headers on both sheets (As I did on post -2). The order of the headers does not make any difference as long as the names are exact match.

  7. #7
    Registered User
    Join Date
    04-20-2014
    Location
    Derby
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: VBA or Macro to merge two worksheets into one

    got it. this is excellent many thanks.

    this is just what I need

    Deek

+ 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. Giant merge macro with varying number of worksheets
    By Knighterist in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2014, 12:21 AM
  2. Need macro to merge data from multiple worksheets
    By Gaurav4141 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-10-2014, 08:03 AM
  3. Macro to merge worksheets
    By Stephen Lopes in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-22-2014, 08:48 AM
  4. Replies: 9
    Last Post: 12-03-2010, 04:37 AM
  5. Macro to merge worksheets
    By dianag365 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2010, 01:25 PM
  6. Macro to Merge Worksheets into a Workbook
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2008, 09:49 AM
  7. Merge worksheets with macro, Need HELP!
    By thepartydj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2007, 03:32 PM

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