+ Reply to Thread
Results 1 to 4 of 4

Summarize data from multiple worksheets

Hybrid View

jarssonn Summarize data from multiple... 06-28-2010, 11:55 AM
Leith Ross Re: Summarize data from... 06-28-2010, 09:54 PM
jarssonn Re: Summarize data from... 06-29-2010, 03:19 AM
Leith Ross Re: Summarize data from... 06-29-2010, 12:47 PM
  1. #1
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    53

    Summarize data from multiple worksheets

    Hi all excel experts,

    I am in process of preparing training records file but unfortunately I get stucked.
    My file will contain about 50 worksheets - one for each of the employees named as employee name (every worksheet will be the same format).
    What I will need is a macro which will pull out data from individual training record sheets into the summary sheet.
    Sounds simple but is not simple for me - I hope somebody will help me with that.
    I have uploaded sample workbook so it will be easier for somebody who will decide to give it a try.

    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Summarize data from multiple worksheets

    Hello jarssonn,

    This macro has been added to the attached workbook. To run the macro, click the button "Summarize" at the top left of the "Summary Sheet".
    'Written: June 29, 2010
    'Author:  Leith Ross
    
    Sub InternalSummary()
    
      Dim LastRow As Long
      Dim R As Long
      Dim Rng As Range
      Dim RngEnd As Range
      Dim SumWks As Worksheet
      Dim Wks As Worksheet
      
        R = 2           'Starting row on the Summary Sheet
        LastRow = 25    'Last row of Internal Training
        Set SumWks = Worksheets("Summary Sheet")
        
          For Each Wks In Worksheets
            If Wks.Name <> SumWks.Name And Wks.Name <> "CATS" Then
              Set Rng = Wks.Range("A10:I10")
              Set RngEnd = Wks.Cells(LastRow, Rng.Column).End(xlUp)
                If RngEnd.Row >= Rng.Row Then
                  Set Rng = Wks.Range(Rng, RngEnd)
                  SumWks.Cells(R, "A") = Wks.Cells(2, "B")   'Name
                  SumWks.Cells(R, "B") = Wks.Cells(3, "B")   'Current Role
                  SumWks.Cells(R, "C") = Wks.Cells(4, "B")   'Site
                  SumWks.Cells(R, "D").Resize(Rng.Rows.Count, 9).Value = Rng.Value
                  R = R + Rng.Rows.Count
                End If
            End If
          Next Wks
          
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-01-2010
    Location
    Worcester, UK
    MS-Off Ver
    Microsoft 365 (subscription)
    Posts
    53

    Re: Summarize data from multiple worksheets

    Hi! Fantastic work - many thanks. Just one simple thing - is this possible that Name, Current Role and Site appears on every line not just in the first one for courses of the same person? This is needed for filtering purpose.
    Many thanks again!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Summarize data from multiple worksheets

    Hello jarssonn,

    I made the changes you wanted. Here is the revised macro. This has been added to the attached workbook.
    'Written: June 28, 2010
    'Updated: June 29, 2010 - Extended Name, Current Role, and Site information to all cells
    'Author:  Leith Ross
    
    Sub InternalSummary()
    
      Dim LastRow As Long
      Dim R As Long
      Dim Rng As Range
      Dim RngEnd As Range
      Dim SumWks As Worksheet
      Dim Wks As Worksheet
      
        R = 2           'Starting row on the Summary Sheet
        LastRow = 25    'Last row of Internal Training
        Set SumWks = Worksheets("Summary Sheet")
        
          For Each Wks In Worksheets
            If Wks.Name <> SumWks.Name And Wks.Name <> "CATS" Then
              Set Rng = Wks.Range("A10:I10")
              Set RngEnd = Wks.Cells(LastRow, Rng.Column).End(xlUp)
                If RngEnd.Row >= Rng.Row Then
                  Set Rng = Wks.Range(Rng, RngEnd)
                  SumWks.Cells(R, "A") = Wks.Cells(2, "B")   'Name
                  SumWks.Cells(R, "B") = Wks.Cells(3, "B")   'Current Role
                  SumWks.Cells(R, "C") = Wks.Cells(4, "B")   'Site
                  SumWks.Cells(R, "D").Resize(Rng.Rows.Count, 9).Value = Rng.Value
                    SumWks.Range("A" & R & ":C" & R + Rng.Rows.Count - 1).Value = _
                      WorksheetFunction.Transpose(Wks.Range("B2:B4").Value)
                  R = R + Rng.Rows.Count
                End If
            End If
          Next Wks
          
    End Sub
    Attached Files Attached Files

+ 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