Solved

Miracle VBA Copy

Posted on 2013-05-10
2
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

734 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