+ Reply to Thread
Results 1 to 11 of 11

Combine data from several worksheets into one with conditions

  1. #1
    Registered User
    Join Date
    03-26-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Combine data from several worksheets into one with conditions

    Hi all,

    I'm looking for help with my data sorting.

    I have 3 different Worksheets with the following data and I would like to combine them into the 4th Worksheet. But there are some requirements:

    1. I’d like to have rows with same serial number under each other (row from Worksheet 1, then from Worksheet 2, and then from Worksheet 3) but so that the order from Worksheet 1 stays unchanged.
    2. Then I’d like to remove any row that contains SP0 in it.

    Sheet1
    CZ32089DM9 U1→NIC1 SwA→SP24
    CZ32089DMD U3→NIC1 SwA→SP23
    CZ32089DMB U6→NIC1 SwA→SP0
    CZ32089D7D U4→NIC1 SwA→SP18

    Sheet2
    CZ32089DM9 U1→NIC2 SwB→SP22
    CZ32089DMD U3→NIC2 SwB→SP0
    CZ32089DMB U6→NIC2 SwB→SP0
    CZ32089D7D U4→NIC2 SwB→SP0

    Sheet3
    CZ32089DM9 U1→ILO SwB→SP41
    CZ32089DMD U3→ILO SwB→SP43
    CZ32089DMB U6→ILO SwB→SP43
    CZ32089D7D U4→ILO SwB→SP39

    And the result would be like this, except at the end I'd like to have rows with SP0 in it deleted.

    Sheet4
    CZ32089DM9 U1→NIC1 SwA→SP24
    CZ32089DM9 U1→NIC2 SwB→SP22
    CZ32089DM9 U1→ILO SwB→SP41
    CZ32089DMD U3→NIC1 SwA→SP23
    CZ32089DMD U3→NIC2 SwB→SP0
    CZ32089DMD U3→ILO SwB→SP43
    CZ32089DMB U6→NIC1 SwA→SP0
    CZ32089DMB U6→NIC2 SwB→SP0
    CZ32089DMB U6→ILO SwB→SP43
    CZ32089D7D U4→NIC1 SwA→SP18
    CZ32089D7D U4→NIC2 SwB→SP0
    CZ32089D7D U4→ILO SwB→SP39

    Is there a formula or macro I could run to get the result I'm looking for?

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Combine data from several worksheets into one with conditions

    Sheet1
    CZ32089DM9 U1→NIC1 SwA→SP24
    CZ32089DMD U3→NIC1 SwA→SP23
    Are the above entries in 1 column or multiple? Do you have a sample file that you could upload with some dummy data so we can understand your data layout?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    09-23-2008
    Location
    UK
    Posts
    137

    Re: Combine data from several worksheets into one with conditions

    Have you tried copying and pasting all from sheet1,2,3 into sheet 4. Then selecting and doing a data sort by the column with the serial.

    To delete the rows with SP0, add a data filter (data>filter>autofilter), then custom filter (from the drop down, select custom), 'contains' (from the drop down select 'contains'), type in "SP0". Then highlight the filtered rows and right-click, delete.

  4. #4
    Registered User
    Join Date
    03-26-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Combine data from several worksheets into one with conditions

    I've included a sample file.
    Data is in 3 columns: Serial, Location, Port

    sample.xlsx

    Chengo

  5. #5
    Registered User
    Join Date
    03-26-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Combine data from several worksheets into one with conditions

    I have a piece of code that works on my sample data but I need some help to make it work in project spreadsheet.
    Code currently calls out Sheets 1, 2 and 3 and put the results in Sheet 4.
    I'd like it to call out data from renamed sheets - NIC1, NIC2 and ILO and put the results in sheet named ORDER.
    I need to change it because I have more sheets in use and some of them are hidden. Also sheets NIC1, NIC2 and ILO are not first 3 sheets in the workbook.

    Please Login or Register  to view this content.
    Any suggestions?

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Combine data from several worksheets into one with conditions

    Try this code instead -
    Please Login or Register  to view this content.
    Last edited by arlu1201; 04-03-2012 at 11:38 AM. Reason: Corrected code

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Combine data from several worksheets into one with conditions

    Arlu, you might want to relook at some of your code:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Combine data from several worksheets into one with conditions

    Thanks shg. Got it corrected.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Combine data from several worksheets into one with conditions

    Please Login or Register  to view this content.
    Last edited by snb; 04-03-2012 at 02:40 PM.



  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Combine data from several worksheets into one with conditions

    Arlu, your sort key and sort range still refer to the active worksheet.
    Last edited by shg; 04-03-2012 at 01:51 PM.

  11. #11
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Combine data from several worksheets into one with conditions

    Quote Originally Posted by shg View Post
    Arlu, your sort key and sort range still refer to the active worksheet.
    Yes shg. I want the sort to be performed on the Summary sheet. I have edited the code to show that.

+ 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