+ Reply to Thread
Results 1 to 13 of 13

Merging: displaying which sheet data comes from when merging sheets

  1. #1
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Merging: displaying which sheet data comes from when merging sheets

    Hey guys, I'm merging 15 days worth of time tickets into one master sheet which I then use to prepare payroll for the period. I've found code that performs this operation, however, there's one critical piece of information missing. When each day's data is dumped onto the master sheet, the code fails to help me identify which worksheet the data is coming from.

    I want to alter the code so that when each day is 'dumped' onto the mastersheet, it either breaks up the days with a blank line (after which I can manually input the dates), or even better, references the worksheet which the data came from. This would simply require displaying the sheet name the rows are being pasted from into a new column on the outside of the range for each row of data.

    Any thoughts?

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    The Worksheet.Name is a string variable.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Merging: displaying which sheet data comes from when merging sheets

    I've just started to learn about macro's and vba, mostly from reading threads off this site.. Is there a simple command to display a string variable?

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    There are two kinds of Excel people - The ones who use formulas in the spreadsheet exclusively and the ones who use VBA exclusively. Ideally - the complete excel programmer should be well versed in both.

    But I'm a VBA person and here's how I'd get the sheet name:

    Please Login or Register  to view this content.
    I've seen formulas in the sheet that also display the name but I didn't save them.

    Hopefully, a formula person or a Compleat Excel Programmer will also hit on this thread.

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    I found it:

    Please Login or Register  to view this content.
    which I doctored from:

    Please Login or Register  to view this content.
    which gives you the fullname.

  6. #6
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Merging: displaying which sheet data comes from when merging sheets

    what if i wanted to output the worksheet name in a cell on a new sheet rather than displaying it in a message box?

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    Hi zed commander,

    I just put it in the message box so that you could see that it worked.
    To display on the output sheet, you'd need either to have it in your input
    or you could assign a cell on the output for it:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Merging: displaying which sheet data comes from when merging sheets

    and what if i want this to happen for somewhere in the neighbourhood of 200-500 lines of data that get merged onto the master sheet? would it help if i were to throw the code I've already gotten up? thanks for your

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    You'd have to decide which field you'd want to tag for each sheet name.

  10. #10
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Merging: displaying which sheet data comes from when merging sheets

    i want to tag the sheet name itself, as each sheet represents all crew activity for the day (i have 15 or 16 sheets, one for each day in the pay period)

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Merging: displaying which sheet data comes from when merging sheets

    Please Login or Register  to view this content.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Merging: displaying which sheet data comes from when merging sheets

    zed commander,

    If you upload a small sample file, dummy data is fine, with before/after format (need to be correct sheet layouts), it will help understand your problem better.

  13. #13
    Registered User
    Join Date
    07-06-2012
    Location
    Edmonton
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Merging: displaying which sheet data comes from when merging sheets

    you are a fantastic individual. keep up the good work, here's some karma

+ 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