VBA Loop - duplicate header copied over

cynthi263

New Member
Joined
May 14, 2019
Messages
19
I am wanting this code to loop through various files in a folder and copy info from each file and paste to a master file - my issue is that after it opens the first file and moves on to the second one, it will paste the header in there as well. All data starts on the same cells "A5" in all the files (A4 is the header) and the header in the master is already added. It only does this on the 2nd file, when it opens the others, it copies just the data and pastes it correctly. Not sure why it's only happening on the 2nd file?

I have tried running it with different files and it doesn't matter which it is, the 2nd one always copies over the header and pastes it in the master file.

1615399154346.png


1615399232782.png
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,151
Office Version
  1. 2016
Platform
  1. Windows
I don't really understand what you were doing here from code. The wb is the workbook where you get the data from, right?

Then why you have another one Workbooks.Open statement? Is this to open Master file? Your code is on another workbook?
 

Watch MrExcel Video

Forum statistics

Threads
1,129,530
Messages
5,636,861
Members
416,946
Latest member
mniceguy81

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