Solved

Create Summary Page Shenanigans

Posted on 2011-03-19
10
245 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
  • 5
  • 4
10 Comments
 
LVL 14

Expert Comment

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

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 41

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 41

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 41

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

773 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