Solved

Create Summary Page Shenanigans

Posted on 2011-03-19
10
250 Views
Last Modified: 2012-06-27
Hello all,

I have a worksheet called "AUT".  It is the fourth worksheet in the workbook.  I would like to copy the range (A26:R43) for all worksheets post the fourth worksheet, underneath each other, into the worksheet titled "AUT".  This will create a summary page that has all the ranges (A26 :R43) from all the other worksheets.

Any help would be greatly appreciated.

Many thanks, Alan.
0
Comment
Question by:Canders_12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 14

Expert Comment

by:theras2000
ID: 35173284
Attach the workbook, or a demo if it's private.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 35173312
Try this:  and see attached spreadsheet demo

The app GatherData goes through every worksheet, copying the range specified.  note, it clears the AUT tab of all data before starting.

Sub GatherData()
Dim mySheet As Worksheet
Dim myOutputCursor As Range
Dim rSize As Integer, cSize As Integer

    rSize = Range("A26:R43").Rows.Count
    cSize = Range("A26:R43").Columns.Count
    
    Sheets("AUT").Select
    Cells.Clear
    
    Set myOutputCursor = ActiveSheet.Range("A1")
    
    For Each mySheet In Application.Worksheets
        If mySheet.Name <> "AUT" Then
            
            myOutputCursor.Resize(rSize, cSize).Value = mySheet.Range("A26:R43").Value
            Set myOutputCursor = myOutputCursor.Offset(rSize, 0)
            
        End If
    Next mySheet

Open in new window

Cheers,

Dave
GatherDataAUT-r1.xlsm
0
 

Author Comment

by:Canders_12
ID: 35173369
Theras2000;

It is sensitive :/ will try to Mock up a quick demo.

Dave;

Almost ideal, is there an easy way to tweak code so it all gets the information for all worksheets that are after the AUT worksheet?

Many thanks.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 42

Expert Comment

by:dlmille
ID: 35173410
Ok - please be clear.  You want to gather information for worksheets AFTER AUT - but that same range, right?

Dave
0
 

Author Comment

by:Canders_12
ID: 35173424
That is correct, apologies for my ambiguity. If it helps "AUT" will ALWAYS be the fourth worksheet.
0
 

Author Comment

by:Canders_12
ID: 35173425
That is correct, apologies for my ambiguity. If it helps "AUT" will ALWAYS be the fourth worksheet.
0
 
LVL 42

Accepted Solution

by:
dlmille earned 500 total points
ID: 35173431
Ok - this copies the same range, but for only those sheets that come AFTER the AUT sheet

see attached demo that its working.

Methodology - figure out the # worksheets, then loop through till "AUT" is found, from that point, copy the data.

Here's the code:

Sub GatherData()
Dim myOutputCursor As Range
Dim rSize As Integer, cSize As Integer
Dim countSheets As Integer, i As Integer, foundAUT As Boolean

    rSize = Range("A26:R43").Rows.Count
    cSize = Range("A26:R43").Columns.Count
    countSheets = ActiveWorkbook.Sheets.Count
    foundAUT = False
    
    Sheets("AUT").Select
    Cells.Clear

    
    For i = 1 To countSheets
        If foundAUT Then
            myOutputCursor.Resize(rSize, cSize).Value = ActiveWorkbook.Sheets(i).Range("A26:R43").Value
            Set myOutputCursor = myOutputCursor.Offset(rSize, 0)
        Else
            If ActiveWorkbook.Sheets(i).Name = "AUT" Then
                foundAUT = True
                Set myaut = ActiveWorkbook.Sheets(i)
                myaut.Activate
                Set myOutputCursor = myaut.Range("A1")
            End If
        End If
    Next i
    
End Sub

Open in new window

Enjoy!

Dave
GatherDataAUT-r2.xlsm
0
 

Author Closing Comment

by:Canders_12
ID: 35173437
Dave,

Excellent solution. Many many thanks for your swift replies.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 35173443
This one's a bit more efficient - starting with the AUT sheet (versus finding it), then going to the sheets.count end...

code (and see attached file):

Sub GatherData()
Dim myOutputCursor As Range
Dim rSize As Integer, cSize As Integer
Dim countSheets As Integer, i As Integer

    rSize = Range("A26:R43").Rows.Count
    cSize = Range("A26:R43").Columns.Count
    countSheets = ActiveWorkbook.Sheets.Count
    
    Sheets("AUT").Cells.Clear
    
    Set myOutputCursor = Sheets("AUT").Range("A1")
    
    For i = Sheets("AUT").Index + 1 To countSheets
        myOutputCursor.Resize(rSize, cSize).Value = ActiveWorkbook.Sheets(i).Range("A26:R43").Value
        Set myOutputCursor = myOutputCursor.Offset(rSize, 0)
    Next i
    
End Sub

Open in new window

Dave
GatherDataAUT-r3.xlsm
0
 

Author Comment

by:Canders_12
ID: 35173450
Above and beyond the call of duty.... Thank you :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question