+ Reply to Thread
Results 1 to 5 of 5

Add data columns and merge specific data sheets into master sheet

  1. #1
    Registered User
    Join Date
    07-15-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    6

    Add data columns and merge specific data sheets into master sheet

    Hi,

    I have a workbook with multiple sheets in it. Some contain raw data and some contain calculations etc. Every month I add a new data sheet that's in the same format as the other data sheets - so i have a sequence of sheets named 12011, 22011, 32011...122011, 12012, 22012, etc.

    I would like help writing 2 pieces of code:

    The first piece of code should add the title "Month" in cell E3, and add the 'number' of that month in the rest of column E.
    So for July, cells E4 to wherever the last record is (they will differ each month), should all contain "7".
    Similarly in cell F3, there should be the title "Year", and the year should be inserted in the rest of the column.
    If possible the month and year should be extracted from the sheet names as detailed above, and the code should run for all the sheets with the month-year naming convention.

    The second piece of code will then select all the data in the monthly data sheets and compile into a master sheet.
    I currently have a piece of code that does something similar, but everytime I add a new sheet, I have to add the sheet name to the code (code attached below).
    (And I only want to copy the month-year named data sheets into the master sheet).

    sorry for the loooong winded question, but any help would be greatly appreciated!

    Please Login or Register  to view this content.
    Last edited by sshahils; 07-15-2011 at 10:25 AM.

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Add data columns and merge specific data sheets into master sheet

    Maybe one way?

    Please Login or Register  to view this content.
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Add data columns and merge specific data sheets into master sheet

    Quote Originally Posted by sshahils View Post
    ... but everytime I add a new sheet, I have to add the sheet name to the code
    hi, sshahils, try to change this code block:

    Please Login or Register  to view this content.
    to this one:

    Please Login or Register  to view this content.
    Last edited by watersev; 07-15-2011 at 10:20 AM.

  4. #4
    Registered User
    Join Date
    07-15-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Add data columns and merge specific data sheets into master sheet

    Thanks guys for the fast responses!

    realniceguy, your 1st code worked perfectly...
    Watersev, your code worked with a slight tweak (changing the cs to ms in lines 3 and 5, since ms was defined as a worksheet in the new code, while I had been using cs in my old code).

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Add data columns and merge specific data sheets into master sheet

    please note that this line looks like this to accept 5 (12011) and 6 (122012) digits:

    Please Login or Register  to view this content.

+ 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