Open workbook copy&paste, save and close Repeat

jpsimmon

New Member
Joined
Apr 9, 2015
Messages
28
Hi guys, I have code to replace some columns in a specific worksheet. I want to apply this to all workbooks in a folder:
So open > paste values > save > close ...next... workbook open > paste values > save > close ... and so on. All Workbooks have the same Worksheet name that it goes into and pastes to: "Atts".

Code:
[/COLOR][COLOR=#333333]Sub Replace()[/COLOR]
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit;">     Workbooks.Open Filename:= _
    "K:\Drive\Path\Sum Stat\File.xlsm"
    Application.AskToUpdateLinks = False
    Windows("Atts Final.xlsm").Activate
    Columns("J:K").Select
    Selection.Copy
     
    
    Windows("File.xlsm").Activate
    Sheets("Atts").Select
    Range("A1").Select
     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    ActiveWindow.Close </code>[COLOR=#333333]End Sub[/COLOR][COLOR=#333333]

Thanks!!


 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,215,537
Messages
6,125,389
Members
449,222
Latest member
taner zz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top