Copy/Paste information from multiple sheets

GillyB

New Member
Joined
Mar 30, 2016
Messages
4
Hi All, hope you're having a great day!

I am currently building a survey spreadsheet for an instructor. Yes I have informed them that there is many programs available for this task but nope, they want Excel.

So my plan is...

Main Spreadsheet called "Results" which the instructor keeps to himself
Survey Spreadsheet that auto-named when they submit the survey (this works perfectly so no problem there)

I want the "Results" spreadsheet to go into every sheet in the folder "Results" and copy the same range ("E4:E15") and then paste (and transpose) into a list in "Results".

Now, I have found code for this, however when I run it, it opens all the sheets and then nothing happens! I have looked through it but I cannot see where I am going wrong. :(

No error occurs, and also this is Excel 2003.

Any help would be MUCH appreciated as the lack of error and anything happening at all is making me go crazy-mad! :eek:

Here's the code:

Sub Transpose()

Range("A4:L200").Select
Selection.ClearContents


Dim spath As String
Dim sfile As String
Dim sht As Worksheet
Dim control As String
Dim nextrow As Long


'ROUTINE TO TRANSPOSE COLUMNS E4 to E15 INTO ROWS IN A MASTER SHEET


spath = ThisWorkbook.Path 'FILE PATH TO MASTER WORKBOOK
control = ThisWorkbook.Name 'DECLARE NAME OF MASTER WORKBOOK


nextrow = 2 'DICTATES WHERE TO START TRANSPOSING DATA - ROW TWO


With Application.FileSearch
.LookIn = spath & "\Results"
.Filename = ".xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then


Set newwkbk = ActiveWorkbook


For I = 1 To .FoundFiles.Count
Workbooks.Open (.FoundFiles(I))
sfile = ActiveWorkbook.Name


For Each sht In ActiveWorkbook.Worksheets


sht.Select


If Application.WorksheetFunction.CountA(Range("E4:E15")) > 0 Then 'CHECK TO ENSURE THERE IS DATA IN THE RANGE


Range("E4:E15").Select
Selection.Copy


'SWITCH TO MASTER SHEET
Workbooks(control).Activate
Sheets("Results").Select 'SELECT WORK SHEET THAT WILL CONTAIN DATA - RENAME ACCORDING TO YOUR SHEET!!
Cells(nextrow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
nextrow = nextrow + 1


End If


Workbooks(sfile).Activate 'SWITCH TO SOURCE DATA WORKBOOK


Next sht 'PROGRESS TO NEXT SHEET IN WORKBOOK


Workbooks(sfile).Activate
Application.CutCopyMode = False
ActiveWorkbook.Close False


Next I
End If


End With


End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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
Back
Top