Quantcast
Viewing all articles
Browse latest Browse all 50068

Vba code to run my macro in all open workbooks

Hi all,

I have a macro to get copy of sheet named "Doc Info" from workbook File 1
to active workbook.


i could do it for one file on any active workbook.

But what i would require is, upon executing this macro , i want this macro to get executed in all open workbooks( could be any numbers )

. i want to move copy of sheet from File 1 to all open workbooks ( which i am doing it manualy for every file )
All these open workbooks could be from any folder , wont be in same folder.

So logic is to execute my macro apply in all open workbooks in my computer.

Below is the code and i have attached file for test


HTML Code:

Sub Copysheet()
Dim wSht As Worksheet
Dim wBk As Workbook
Dim wBk1 As Workbook

Set wBk = ActiveWorkbook 'Workbooks("File 2.xls")
Set wBk1 = Workbooks("File 1.xlsm")
Set wSht = wBk1.Sheets("Doc Info")

wSht.Copy before:=wBk.Sheets(1)

End Sub

Attached Files

Viewing all articles
Browse latest Browse all 50068

Trending Articles