Hi Experts
I am facing issue with something similar to the following thread – http://windowssecrets.com/forums/showthread//147970-VBA-Code-to-Open-Workbook-and-copy-data-into-destination-workbook
My requirement is little different. In my case I have more than 14 workbooks saved in a common folder. Each workbook contains data 3 sheets/tab in it. I want data say sheet1 from all the 14 workbooks to be saved in a new workbook with its same tab name in a sequence. I mean the new sheet will have 14 sheets one after the other.
I want sheet2 in same passion in a new workbook and Sheet3 as well in a new workbook.
Please let me know if I am unclear here.
Regards,
JD
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
VBA Code to Open Workbooks saved in a common folder and copy data into destination workbook
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » VBA Code to Open Workbooks saved in a common folder and copy data into destination workbook
- This topic has 4 replies, 2 voices, and was last updated 10 years ago.
AuthorTopicWSJaggi
AskWoody LoungerMay 18, 2015 at 4:35 am #500004Viewing 3 reply threadsAuthorReplies-
WSduthiet
AskWoody LoungerMay 27, 2015 at 11:26 am #1506511Below is what I think you are looking for.
Prior to running the macro “MyCopy”
1 You will need to have open 3 Excel files with one worksheet
A – Test of Master.xlsm
B – Test of Master2.xlsx
C – Test of Master3.xlsx2 The Macro is set to begin in the Workbook “Test of Master.xlsm”
Worksheet 1 Cell “C15”
This cell and all the cells below it must have the full pathname of the Worbooks with Data3 The fastest way to get this pathnames is to use Windows Explorer and go to the Folder with the files
Select all the files CTRL + A
Hold down “SHIFT” KEY and Right Click mouse.
Select “Copy as path”
Retun to the Workbook “Test of Master.xlxm” go to Sheet1 Cell “C15” and paste the clipboard4 Put the following Code in the Test of Master.xlsm
Sub MyCopy()
Dim Aa As Integer
Dim Ab As Integer
Dim Fname As String
Dim Fname1 As String
Aa = 1
Ab = 15
Worksheets.Item(1).Activate
Cells(Ab, 3).Select
Do While ActiveCell “”
Workbooks(“Test of Master.xlsm”).Activate
Worksheets.Item(1).Activate
Cells(Ab, 3).Activate
Fname = ActiveCell.Value
Workbooks.Open (Fname)
Fname1 = ActiveWorkbook.Name
Worksheets.Item(1).Copy After:=Workbooks(“Test of Master.xlsm”).Worksheets.Item(Aa)
Workbooks(Fname1).Activate
Worksheets.Item(2).Copy After:=Workbooks(“Test of Master2.xlsx”).Worksheets.Item(Aa)
Workbooks(Fname1).Activate
Worksheets.Item(3).Copy After:=Workbooks(“Test of Master3.xlsx”).Worksheets.Item(Aa)
Workbooks(Fname1).Close SaveChanges:=False
Aa = Aa + 1
Ab = Ab + 1
Workbooks(“Test of Master.xlsm”).Activate
Worksheets.Item(1).Activate
Cells(Ab, 3).Activate
Loop
End Sub5 Run the Macro
Good Luck TD
-
WSJaggi
AskWoody Lounger -
WSduthiet
AskWoody LoungerMay 29, 2015 at 10:48 am #1506903What I provided should work.
I ran the macro and got the same results as in your Output 1; Output 2; and Output 3
Attached are MyData01.xlsx [data file one]
MyData02.xlsx [data file two]Aslo attached are the blank output files which are Output One Output Two and Output Three – to use the macro these files must be opened and their names must be Output One.xlsm; Output Two.xlsx; Output Three.xlsx.
In Output One.xlsm you must entet the full pathname of each file you want opened and copied to the Output Workbooks. [One Two Three]
In the sample I have set up only two workbooks; but you can put as many pathnames as you want, but they all must be in column C and there can be no blank rows between the names.
Once you have put the full filepath of the exact location of the files on your computer in C15 and C16 AND you have open Output One; Output Two and Output Three run the macro.
You should get the desired results in the desired sequence.
Good luck
TD -
WSJaggi
AskWoody Lounger
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Very Quarrelsome Taskbar!
by
CWBillow
21 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
2 hours, 25 minutes ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
3 hours, 43 minutes ago -
Is your battery draining?
by
Susan Bradley
3 hours, 8 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
5 hours, 40 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
6 hours, 16 minutes ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
9 hours, 31 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
14 minutes ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
2 hours, 46 minutes ago -
National scam day
by
Susan Bradley
5 hours, 41 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
2 hours, 57 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
1 day, 7 hours ago -
Tools to support internet discussions
by
Kathy Stevens
1 day, 14 hours ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
22 hours, 25 minutes ago -
AI is good sometimes
by
Susan Bradley
1 day, 14 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
1 day, 4 hours ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
2 days, 14 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
2 days, 13 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
2 days, 17 hours ago -
Excessive security alerts
by
WSSebastian42
1 day, 8 hours ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
3 days, 2 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
7 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
2 days, 14 hours ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
1 day, 7 hours ago -
OS news from WWDC 2025
by
Will Fastie
17 hours, 44 minutes ago -
Need help with graphics…
by
WSBatBytes
1 day, 22 hours ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
3 days, 18 hours ago -
Totally remove or disable BitLocker
by
CWBillow
2 days, 17 hours ago -
Windows 10 gets 6 years of ESU?
by
n0ads
2 days, 20 hours ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
4 days, 5 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.