**Update 9/21/22- Updated VBA code located below. I have the sheets being copied from one workbook to the target workbooks; however its not copying only the worksheet with a name that is contained in the target workbook's file name. Its copying all tabs to each file in target location. I think I have the order of tasks messed up. It seems like the copying all happens when I debug on "Set wb = Workbooks.Open(wbFile.Path)". Thank you in Advance!
I am looking to create a nested loop or at least I think that will accomplish this task. I have a worksheet with individual sheets that I want to copy to existing workbooks. The target workbooks' file names contain the tab's name within the file name. I want to loop through each worksheet and add it to the beginning of the matching workbook.
I believe my current struggle is setting the target workbook so i can make changes to it within the 2nd loop. Thank you in Advance!
'''
Sub updates()
Dim ws As Worksheet
Dim wb As Workbook
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder("C:\Users\report")
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Index > 2 Then
'folder location
For Each wbFile In fldr.Files
On Error Resume Next
If fso.GetExtensionName(InStr(wbFile.Name, ws)) > 0 Then
Set wb = Workbooks.Open(wbFile.Path)
ws.Copy Before:=wb.Sheets(1)
ActiveWorkbook.Save
ActiveWorkbook.Close SaveChanges:=True
End If
Next wbFile
End If
Next ws
Application.ScreenUpdating = True
End Sub
'''