VBA code assistance [copy range and paste range]

jamesplant77

New Member
Joined
Nov 13, 2015
Messages
4
I have an aggregator tool that used VBA to copy 6 rows of data from a workbook, paste the data into one row in the aggregator workbook and then continue with all the files in a directory until all the files were looped. I now need to copy 6 rows of non-adjacent data, but paste this into 6 rows of data in the aggregator workbook, before continuing the process for all the files. This is the VBA that I am using:

Sub copyNonAdjacentCellData()
Dim myFile As String, path As String
Dim NextRow As Long, col As Long

path = "C:\Users\JamesPlantCloud21\Desktop\Timesheets - STH Staff\"
'C:\Users\JamesPlantCloud21\Desktop\Timesheets - STH Staff
myFile = Dir(path & "*.xlsx")

Application.ScreenUpdating = False

Do While myFile <> ""
Workbooks.Open (path & myFile)
Windows(myFile).Activate

Set copyrange = Sheets("JAN 23").Range("A9:B14,C9:K14,AQ9:AT14")

Windows("Timesheet_Aggregator_STH.xlsm").Activate

NextRow = ThisWorkbook.Sheets("STH_STAFF").Cells(Rows.Count, 1).End(xlUp).Row + 1


col = 1
For Each cell In copyrange
cell.Copy


Cells(NextRow, col).PasteSpecial xlPasteValues

col = col + 1

Next

Windows(myFile).Close SaveChanges:=False

myFile = Dir()

Loop

Range("A:O").EntireColumn.AutoFit

Application.ScreenUpdating = True


End Sub


I am not an expert in VBA, but I believe it's something to do with the paste function in the code.

Would appreciate some expert assistance!!!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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