VBA to find next empty row in worksheet isn't working!!!

jimbo1977

New Member
Joined
Oct 15, 2019
Messages
1
Hi guys, i'm not amazing with VBA but can take stuff and change it to suit my requirements, although this code isn't finding the next empty row, it's just pasting data on top of data, so instead of getting 20 rows of data, i'm just getting 1 and it's really infuriating!!

I have a multitude of finance workbooks that each have a cover sheet, I am trying to obtain all the data in these cover sheets and then paste into headers, so I can produce a monthly automated finance report - this is the code I am using and like I said, it's not finding the nect empty row to paste into:

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


path = "P:\Finance Trackers"
myFile = Dir(path & "*.xlsx")


Application.ScreenUpdating = False


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


Set copyrange = Sheets("MONTHLY REPORT").Range("N7,E9,E5,E7,W5,W7,W9,E11,N9,D5,E15,E17,E19,E21,N17,N19,N21,X21,N26,X26")


Windows("Finance_Tracker_Aggregator.xlsm").Activate


erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row


col = 1
For Each cel In copyrange
cel.Copy


Cells(erow, col).PasteSpecial xlPasteValues


col = col + 1


Next


Windows(myFile).Close savechanges:=False


myFile = Dir()


Loop


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


Application.ScreenUpdating = True




End Sub



Really hoping that someone can help!!!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Are you looking to paste the values onto the active sheet, or a specific sheet?
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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