Solved

Miracle VBA Copy

Posted on 2013-05-10
2
441 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
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.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

760 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

18 Experts available now in Live!

Get 1:1 Help Now