+ Reply to Thread
Results 1 to 18 of 18

Merging Multiple Worksheets - cell selection & translation using VBA

  1. #1
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Merging Multiple Worksheets - cell selection & translation using VBA

    I am new to this forum, so please forgive me if I have duplicated an existing thread. I have searched high and low for a problem similar to mine but have had no luck after several days of trying and tinkering. I also apologies if the title of this thread does not accurately reflect what I am trying to achieve - often knowing what the key buzz words are that describe your problem result in being able to find a suitable / similar example and reach a solution.

    As per the title, I am looking to merge contents from multiple worksheets into a a single worksheet using VBA. Each seperate worksheet has the exact same layout and is considered a data entry form where data is captured relating to different people's skills and their relative level / rating. From here, I can then use a pivot table to filter and assess the data and skill levels to assist with decision making got resource and capability when undertaking new or existing projects, as skill gaps or strengths may be identified.

    The problem I am experiencing is that I am not wishing to merge the data into the new summary sheet in the same format as the worksheet sources due to how the 'form' worksheets are laid out. I have attached a blank copy of my form to this thread to help readers visualise the layout.

    I have multiple skills (vertically in the B column) mapped to the different stages of project lifecycle experience (in columns D to L) and then a relative score within the cells where the two intersect. There are then gaps in the rows to segregate different skill groups, with multiple skills within each group - for example skill group 1 uses rows 10 to 30, then skill group 2 uses rows 32 to 47, as row 31 is title for skill group 2, etc and so on.

    My intention is to extract all of the values for each person (worksheet), which may be up to 100 people, and display it in the example shown in the summary tab - effectively each cell from the form is translated into a row which shows the relative lookup info that one would follow if interpreting the value from the form. For example, using cell D10 from the blank form, the newly merged row on the summary sheet would consist of

    - name (from either the merged cell C4 to F4 or from the name of the tab/worksheet)
    - Skill 1
    - Lifecycle Stage 'R'
    - the value assigned to this person

    ....and this is done for each cell, across all worksheets.

    I hope this is all making sense.

    Note that I have not included all of the worksheets within the spreadsheet (raw data set) as these contain sensitive data on individuals. The spreadsheet I have uploaded and attached has been modified to contain only the blank sheet which is the form that is populated by each person, and the summary sheet showing an example of how I wish to extract and merge the data from each worksheet, as described in the bullet points above.

    I really would appreciate any help or guidance you may be able to offer as I have been working on this for several days now with no joy as I cannot find an example that is similar to it which requires the data to be manipulated during the merge to the summary sheet. No matter how small or trivial you may deem the advice, I would be most grateful and it may be something so simple that needs to be done in order to translate and select the relevant data for merging.

    Thanks in advance,

    Matthew
    Electronics & Telecoms Engineer
    Using: MS Excel 2007 / 2010
    Attached Files Attached Files
    Last edited by rudupoo66; 03-14-2016 at 03:34 PM. Reason: attempt to make title clearer.

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    This is how I understand your problem.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Thank you so much for your reply.

    I will attempt to run this tomorrow when i have the other data tabs available to me so can see if the new summary sheet populates correctly.

    Will report back either way - thanks.

    Matt

  4. #4
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    I can't seem to get the VBA to run - is this to be placed into the code for "This workbook" ? I am unable to run this as I receive an error message: "Run-time error '429'. Active X can't create an object".

    I am currently running this temporarily on a mac laptop with MS office as I am not in the office on a windows computer today - does this have anything to do with it? If needs be, I could provide a copy of the populated spreadsheet removing any sensitive data to assist any further?

    Thanks again for your help - it really is appreciated as this is starting to send me crazy.

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    It should run on Windows PC, not Mac...

  6. #6
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    I have tried it again now on my pc and received the following error when using a spreadsheet that has been populated with multiple tabs as people's skills sets:

    Runtime error "9", subscript out of range.

    After adding some new tabs to the workbook with populated cells acting as a form I received the following error.

    Subscript out of range

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Most probably you have miss-spelled worksheet name.

    If you upload a workbook with same data and the result that you want, it will clearer.

  8. #8
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    I have attached the spreadsheet i am working on, that is populated with data. The summary worksheet provides an example of the desired format of the merged data.

    If the merged cells (row) between the cells on the blank form is causing issues with the loop when attempting to merge the data to the new summary sheet, I have modified this by removing the cells and creating a new column with colours to help segregate the different skill groups. If this is preferable please suggest and I can populate the spreadsheet using the newly modified blank form with no merged cells to segregate skill groups.

    Are you able to put a few brief comments on your VBA code so I can follow what you are trying to do? I am used to coding in C and rarely use VBA so can struggle to follow VBA at times.

    I hope all this is making sense - I am trying to describe the problems and what I am intending to do as best I can.

    Thanks you again - really do appreciate your help!

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    The code I have posted is to generate the report only if the data in intersection is not empty.
    If you want all even no data then
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Jindon - you absolute hero! that is literally just what I was after - THANK-YOU so much.

    I have had a little play with it and am now trying to get the code to work with a slightly modified version of the template form / worksheets which has removed the separator (intersection) and shifted the columns right by 1. Now not populating the summary table properly, mainly due to the loop parameters. Are you able to have another quick look at why it hasn't worked from my change from "d10" to "e10"?

    Any comments you could add would also no doubt help me in changing it in future should it require changing due to new columns or rows in the blank / template form.

    I have attached the new version.

    Again - thank you so much. Really appreciative!

    Matt

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Replace "Private Sub GetData" sub procedure with
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    i will try now - again - THANK YOU SO much for your help!!

  13. #13
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Jindon - Thank you so much! it works! really, really appreciate all your help - amazing.

    Thanks again

  14. #14
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    I am having difficulty with a set case. I am aiming to use the code below, but where I have explicitly stated the names of the worksheets that I am not wanting to run the GetData function ("Summary", "Analysis", "Summary Example", "DASHBOARD"), I also would like to add another condition where any worksheet that contains a specific character (Eg "@") does not run the function. The general idea is that if I change the name of a worksheet from something like "Sheet 1" to "@Sheet 1" the GetData function will not run for this worksheet in addition to the worksheets previously stated.

    I understand that the .Contain("") returns a boolean value - which is what is causing me confusion and issues.

    If you have any help, ideas or suggestions I would veyr much appreciate any help, as always.

    Matt

    The code I am running is shown below:


    Sub test()

    Dim ws As Worksheet, AL As Object

    Set AL = CreateObject("System.Collections.ArrayList")

    For Each ws In Worksheets

    Select Case ws.Name

    Case "Blank Form", "Summary", "Analysis", "Summary Example", "DASHBOARD"

    Case

    Case Else: GetData ws, AL

    End Select

    Next

    With Sheets("summary").[a3].CurrentRegion.Offset(1)

    .ClearContents

    .Resize(AL.Count).Value = Application.Index(AL.ToArray, 0, 0)

    End With

    End Sub



    Private Sub GetData(ws As Worksheet, AL As Object)

    Dim a, i As Long, ii As Long

    a = ws.[a6:m72].Value

    For i = 4 To UBound(a, 1)

    For ii = 5 To UBound(a, 2)

    AL.Add VBA.Array(ws.[d4].Value, a(i, 3), a(2, ii), a(i, ii), a(i, 4))

    Next ii, i

    End Sub

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

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    1)
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    2)

    Try
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    Re: Merging Multiple Worksheets - cell selection & translation using VBA
    I am having difficulty with a set case. I am aiming to use the code below, but where I have explicitly stated the names of the worksheets that I am not wanting to run the GetData function ("Summary", "Analysis", "Summary Example", "DASHBOARD"), I also would like to add another condition where any worksheet that contains a specific character (Eg "@") does not run the function. The general idea is that if I change the name of a worksheet from something like "Sheet 1" to "@Sheet 1" the GetData function will not run for this worksheet in addition to the worksheets previously stated.

    I understand that the .Contain("") returns a boolean value - which is what is causing me confusion and issues.

    If you have any help, ideas or suggestions I would veyr much appreciate any help, as always.

    Matt

    The code I am running is shown below:

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    This post was a Duplicate post - please ignore and see new post below.
    Last edited by rudupoo66; 09-15-2016 at 03:37 AM. Reason: Duplicate

  18. #18
    Registered User
    Join Date
    03-14-2016
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    13

    Re: Merging Multiple Worksheets - cell selection & translation using VBA

    I am still having issues with post #16 shown above and cannot seem to get the .contain functionality to work in conjunction with the select case where the worksheets to be omitted from the function getdata.

    Any help really would be very much appreciated.

    Thanks

    Matt

+ 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. Need help merging multiple worksheets
    By Ycastro9194 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-16-2015, 11:11 AM
  2. [SOLVED] Merging Multiple Worksheets Into One...
    By mrmwangi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-31-2014, 01:00 AM
  3. Merging multiple workbooks (with multiple worksheets) in to one master sheet
    By inkandpaint in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2012, 09:46 AM
  4. merging multiple excel worksheets
    By DJBittner in forum Excel General
    Replies: 3
    Last Post: 10-20-2010, 05:57 PM
  5. Merging multiple worksheets
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2010, 06:46 PM
  6. [SOLVED] perform: Merging multiple worksheets
    By commissionerwalker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-07-2006, 12:30 PM
  7. merging data from multiple worksheets
    By peadar in forum Excel General
    Replies: 4
    Last Post: 02-10-2005, 05:14 PM

Tags for this Thread

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