Hi all-
I've been browsing this forum for something like this but I haven't come across something similar to mine. I'd like to loop through all the sheets and find words that matches the excel file on the server, and if it matches then it pulls and copies the "Input" sheet in the excel file that is on the server. My current code pulls in only one file. How do I make it so it loops through all sheets and matches the name? I hope this makes sense.
PHP Code:
Sub CopyWIW()
Dim WS As Worksheet
Dim wbTarget As Workbook 'WIW file
Dim wbThis As Workbook 'Observe report
Dim strName As String 'name of the source sheet/ target workbook
Set wbThis = ActiveWorkbook
'get the active sheetname of the book
strName = ActiveSheet.Name
'open a workbook that has same name as the sheet name
Set wbTarget = Workbooks.Open("\\ReliabilityEngineering\WarrantyImprovementWorkbooks\" & strName & ".xlsm")
'select cell A1 on the target book
wbTarget.Sheets("Input").Activate
Range("A5:Q5" & Cells(Rows.Count, "A").End(xlUp).Row).Copy
wbThis.Activate
'Range("A1").Select
Range("A1").PasteSpecial
'close the workbook
wbTarget.Close
'activate the source book again
wbThis.Activate
'clear memory
Set wbTarget = Nothing
Set wbThis = Nothing
End Sub
Bookmarks