Solved

Miracle VBA Copy

Posted on 2013-05-10
2
452 Views
Last Modified: 2013-05-10
Hello,

There is a workbook called SRC. It has a sheet called “BufferThis”.
Now, there is a folder with 100 xlsm files.
I need to go through each xlsm file in that folder and add the worksheet “BufferThis” of SRC workbook to each of the xlsm files.
Whats the VBA to do this?

tHanks
0
Comment
Question by:Rayne
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39156544
Try this macro
You will have to change the file path on line 9
Run the macro with the “BufferThis” sheet active
Sub wstoall()
Dim fnam As String
Dim fpath As String
Dim twb As Workbook
Dim swb As Workbook
Dim sws As Worksheet
Set swb = ActiveWorkbook
Set sws = ActiveSheet
fpath = "C:\Documents and Settings\Administrator\My Documents\"
fnam = Dir(fpath & "*.xls*")
Do While fnam <> ""
    Set twb = Workbooks.Open(fpath & fnam)
    sws.Copy twb.Sheets(1)
    twb.Close True
    fnam = Dir
Loop
End Sub

Open in new window

0
 

Author Comment

by:Rayne
ID: 39156584
Hello Ssaqibh,
That worked like a charm. Thank you as always ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Outlook Free & Paid Tools
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now