+ Reply to Thread
Results 1 to 8 of 8

Concatenating multiple cells to a single cell between 2 tabs

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    Nairobi, Kenya
    MS-Off Ver
    Excel 2003
    Posts
    9

    Concatenating multiple cells to a single cell between 2 tabs

    Hey guys. I'm pretty new at VBA and macros as it is and I have a certain problem. The objective I’m aiming at is to copy the following information from the input excel sheet to the sheet 2 excel Tab in a specific format.
    I have 5 columns (course, code, fee, year, avg) for 5 students in sheet 1. These are based on the enter and leave times. I want to to have either VBA code or macro that can concatenate the data in these columns into single cells in sheet 2 such that such that they are based on the time in the "enter" column in sheet 1 and arranged in this format: (course, code, avg, fee, year). I have attached the necessary document and provided an example for 1 cell in sheet 2.
    Please assist me as I have no clue as to get around this. Thanks a bunch!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Concatenating multiple cells to a single cell between 2 tabs

    See attached file where I added this macro:
    Please Login or Register  to view this content.
    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    Nairobi, Kenya
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Concatenating multiple cells to a single cell between 2 tabs

    Thanks a bunch!! That was exactly what I needed!!
    By the way, does the same code work for another tab if all I do is to change the column numbers denoted in the code and the tab number?? Lets say for sheet 3, I want to concatenate values from sheet 1 based on other additional columns with different column numbers.
    Regards,
    Harry

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Concatenating multiple cells to a single cell between 2 tabs

    Yes, if you change the row:
    Please Login or Register  to view this content.
    in
    Please Login or Register  to view this content.
    the variable sh2 will refer to sheet3.
    Regards,
    Antonio

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    Nairobi, Kenya
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Concatenating multiple cells to a single cell between 2 tabs

    I've tried changing the sheet number but it brings me a run-time error 6:overflow. I think the problem lies with the data format since I want to use a time in this instance instead of an integer. But I don't know how to put that into code.
    Please check the attached document to see where I could have gone wrong.

    Regards,
    Harry.

  6. #6
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Concatenating multiple cells to a single cell between 2 tabs

    In the file you attached the command box in sheet3 is linked at a macro 'aaa' that is not present in the workbook.
    I copie my macro1 in macro2 (where I changed sh2 references to sheet3) and then I assigned macro2 at the command button.
    Regards,
    Antonio

  7. #7
    Registered User
    Join Date
    06-07-2011
    Location
    Nairobi, Kenya
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Concatenating multiple cells to a single cell between 2 tabs

    Sorry for bothering, but how do you space the concatenated results in the cell?

  8. #8
    Registered User
    Join Date
    06-07-2011
    Location
    Nairobi, Kenya
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Concatenating multiple cells to a single cell between 2 tabs

    Oh, I spaced them. Thanks so much for your help!

    Regards,
    Harry.

+ 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