Solved

Miracle VBA Copy

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

762 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