VBA - Transpose and xlPasteValues from multiple excel files to master

bubblystace

New Member
Joined
Dec 5, 2017
Messages
8
Hi All,

Basically I am trying to copy hundreds of new files weekly into one Master.
Each file (see https://ufile.io/bh1z1) has a "GPI" sheet with data in D4:D300, which I need to transpose and paste as values into a Master.

I have hit some roadblocks with my current code. It is running but only giving me a filename and no data.

Thanks a lot for any help! :biggrin:

Sub CopyAll()


FileType = "*.xlsx*"
FilePath = "G:\Statewide\Condition Assessment\GEH INSPECTIONS\2017-18 Condition Assessment\CQ\GPI ALCA"


Dim OutputCol As Variant
Dim Curr_File As Variant
Dim FldrWkbk As Workbook


OutputCol = 1


ThisWorkbook.ActiveSheet.Range(Cells(1, OutputCol), Cells(1, OutputCol)) = FilePath & FileType
OutputCol = OutputCol + 1


Curr_File = Dir(FilePath & FileType)


Do Until Curr_File = ""
Set FldrWkbk = Workbooks.Open(FilePath & Curr_File, False, True)
Sheets("GPI").Range("D4:D300").Copy


Workbooks("GPI Master.xlsm").Activate
Sheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)
ActiveSheet.Paste
OutputCol = OutputCol + 1


FldrWkbk.Close SaveChanges:=False
Curr_File = Dir
Loop
Set FldrWkbk = Nothing
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi & welcome to the board.
Assuming that GPI ALCA is a folder name, add an \ to the end of your filepath.
You might also want to remove this line
Code:
ActiveSheet.Paste
 
Upvote 0

Forum statistics

Threads
1,216,156
Messages
6,129,192
Members
449,492
Latest member
steveg127

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