+ Reply to Thread
Results 1 to 20 of 20

Combine sheets into one excluding a specific sheet and arrange data accordingly

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Combine sheets into one excluding a specific sheet and arrange data accordingly

    Hello,

    I would like to ask if anyone knows how to combine all sheets in a workbook into one master sheet excluding the "Input" sheet.

    Since all other sheets are stock data pulled from yahoo, they contain similar information in the same rows and columns.

    I need the combined sheet to look exactly like the "result" sheet in the workbook.

    Could you please review and help?

    Thanks
    Attached Files Attached Files

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Try the attached.
    Attached Files Attached Files
    Last edited by AB33; 02-13-2017 at 05:53 PM.

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    I mixed-up the date format with UK's date.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Thank you for the quick response. However, the result when I ran the macro was not the same as my original result tab.

    The date is way different and longer than the date range in each tab.
    I want to pull the adj close price of each tab into a result tab with columns that associate with the tab name.
    If the sheet is blank how can we run a macro that will generate the result as my original result tab? I'm looking at the perspective that the macro will create a new tab that generate the result as my result tab sample.

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Okay! My code is completely wrong. I will correct it in a few minutes

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    I have now changed the code. I am not sure though which sheets of column A are used to get the dates in the result sheet.

    My out put in column B is not the same as the result sheet, but it is the same data as the Sheet AVNW.
    Attached Files Attached Files
    Last edited by AB33; 02-13-2017 at 07:02 PM.

  7. #7
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Thank you for the attached.

    I guess the macro can only run when there are value in row 1 as header. Can we change the code so that A1 always names " Date" and B1, C1, ..., AA1 pull the value from the input tab starting from A2?
    Last edited by tantcu; 02-14-2017 at 03:58 PM.

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Well, the headers in rows 1 in sheet result are driven from that sheet.
    Why do you want to delete that sheet any way? Are not the data merged in to that sheet? Where the merged data will got then?
    Last edited by AB33; 02-14-2017 at 04:02 PM.

  9. #9
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    I want to be able to create a automatic master/result sheet when we run the macro due to the process.

    The process is I will enter the list of stocks in Input sheet then it will retrieve data for each stock from the list. Then I will run your macro to combine them all into another sheet automatically.

    Can we modify the code to be able to do that?

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    So, will the column headers in sheet result come from sheet Input column A or the sheet names?
    My question is why do you want to delete sheet Result? What happens to the merged data when you delete that sheet? The code as it is now automatically creates that sheet if it does not exist. If it does, it just clears the cells except the header.

    You have dates in all sheets of column A. Which sheet did you use to populate column A in result sheet?

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    See if this works for you. If not, you need to show me your desired output.
    Attached Files Attached Files

  12. #12
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    1. If you can generate the header by sheet name except sheet "Input" that would be fine. I think it would be easier for coding when the header come from the input sheet. Either way would be okay.
    2. I want to delete the result sheet just in case if I started a brand new sheet and data; I can use your code in any file.
    3. You can pull the dates from any stock data sheets as they will be all the same.

  13. #13
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    From your code. You copy the date from the sheets AVNW. Can we modify the code to make it more dynamic which mean the tab may have different name if I have different stock data pulled?
    Can we just use the date from the sheet (2) as reference to pull dates?
    Last edited by tantcu; 02-14-2017 at 05:04 PM.

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Amended one. This ignores sheet Input and picks the names from each sheet.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Could you help address the issue to pull the date from the second sheet but the Input sheet as reference? Your current code has it to pull from the specific sheet with name. I wanted to make it more dynamic because the name may be different when I pull different stock data.

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    There are only two ways of referring to a sheet. By name( Or code name) or index. Index is the position of the worksheet with in the sheet collection. So, if you want to use index, you have to make sure that sheets are on the same order. If not, it will mess your output.
    You only need to change one line on the first code.

    Sheets("AVNW").Range("A1:A" & Sheets("AVNW").Range("A" & Rows.Count).End(xlUp).Row).Copy ms.Range("A1")

    INTO

    Sheets(2).Range("A1:A" & Sheets(2).Range("A" & Rows.Count).End(xlUp).Row).Copy ms.Range("A1")

  17. #17
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Thank you very much. I'm sorry that I need to ask if we can sort the column A so that the earliest date appear first and ascending to the latest date at the bottom?

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Try the attached.
    Attached Files Attached Files

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

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    I have updated the wrong version. This is the correct amendment to the first code.
    Attached Files Attached Files

  20. #20
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Combine sheets into one excluding a specific sheet and arrange data accordingly

    Thank you very much. It's working well. I can close this post now.

+ 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: 0
    Last Post: 10-12-2015, 10:02 AM
  2. Replies: 3
    Last Post: 01-27-2013, 07:23 PM
  3. [SOLVED] Copy All Visible Sheets To New Workbook Excluding Specific Sheets
    By ezrizer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-19-2012, 02:19 PM
  4. [SOLVED] Macro to combine specific sheets into master sheet
    By JakubPrchal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2012, 08:34 AM
  5. Macro to combine data from 4 specific sheets into 1
    By kempezzzz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2012, 11:55 AM
  6. Copy specific cell from multiple sheets to summary - excluding some sheets
    By kabammi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2012, 09:27 AM
  7. How do you combine data from 5 sheets to 1 sheet?
    By geng in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2010, 08:33 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