Copying Worksheet Contents

hellorich

New Member
Joined
Mar 12, 2009
Messages
5
I have a workbook with 300 tabs. Each tab contains 2 columns in exactly the same position starting in cell A8 and ending in cell B37 (30 rows). The first column in each tab contains a list of questions and the second column contains responses to those questions consisting of text and numbers. I am trying to create a summary worksheet in the same workbook by having a macro copy the data from the second column in each worksheet and paste the results to the summary worksheet tab BUT transposed horizontally so that there will be 300 rows of data in 30 columns. The first column in each tab should be ignored as it will function as the header row only in the summary worksheet. Any ideas would be greatly appreciated.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

onlyadrafter

Well-known Member
Joined
Aug 19, 2003
Messages
5,703
Platform
  1. Windows
Hello,

is this working as expected?

Code:
Sub COPY_TO_SUMMARY_SHEET()
    For MY_TABS = 2 To ActiveWorkbook.Sheets.Count
        With Sheets(MY_TABS)
            .Range("B8:B37").Copy
            Sheets("SUMMARY").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
                False, Transpose:=True
        End With
    Next MY_TABS
End Sub

Have assumed the first tab is SUMMARY and the other 300 tabs follow after this one.
 
Upvote 0

Yard

Well-known Member
Joined
Nov 5, 2008
Messages
1,929
Hi, try
Code:
Option Explicit
Sub CompileAnswers()
Dim ws, wsSummary As Worksheet
Dim i As Integer, j As Integer
Const intNumQuestions As Integer = 30
Application.ScreenUpdating = False
i = 1
Set wsSummary = ThisWorkbook.Worksheets("Summary")
wsSummary.UsedRange.ClearContents
For Each ws In ThisWorkbook.Worksheets
    If ws.Name = wsSummary.Name Then GoTo NextWs
    If i > 1 Then GoTo JustAnswers
    For j = 1 To intNumQuestions
        ws.Cells(j, 1).Copy
        wsSummary.Cells(1, j + 1).PasteSpecial xlPasteValues
    Next j
 
JustAnswers:
 
    For j = 1 To intNumQuestions
    ws.Cells(j, 2).Copy
    wsSummary.Cells(i + 1, j + 1).PasteSpecial xlPasteValues
    wsSummary.Cells(i + 1, 1) = ws.Name
    Next j
 
i = i + 1
NextWs:
Next ws
Application.ScreenUpdating = True
End Sub

edit: not quite as slick as onlyadrafter!
 
Upvote 0

Forum statistics

Threads
1,191,165
Messages
5,985,039
Members
439,935
Latest member
Monty238

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top