ferocious12
Member
Hi All,
I have one worksheet that need to be copied to 10+ workbooks saved in a folder. I don't want to open the target workbooks for copying purposes. I have the following macro to copy the activesheet and can only select one workbook. Can you help me to increase the selection to multiple workbooks to copy the activesheet to all the workbooks in a folder.
Thanks
I have one worksheet that need to be copied to 10+ workbooks saved in a folder. I don't want to open the target workbooks for copying purposes. I have the following macro to copy the activesheet and can only select one workbook. Can you help me to increase the selection to multiple workbooks to copy the activesheet to all the workbooks in a folder.
Thanks
Code:
Public Sub CopySheetToClosedWorkbook()
Dim fileName
Dim closedBook As Workbook
Dim currentSheet As Worksheet
fileName = Application.GetOpenFilename("Excel Files (*.xlsx), *.xlsx")
If fileName <> False Then
Application.ScreenUpdating = False
Set currentSheet = Application.ActiveSheet
Set closedBook = Workbooks.Open(fileName)
currentSheet.Copy After:=closedBook.Sheets(closedBook.Worksheets.Count)
closedBook.Close (True)
Application.ScreenUpdating = True
End If
End Sub