PDA

View Full Version : VBA code to copy and paste a sheet from a workbook containing a particular name.



Swaminathann
08-20-2015, 01:08 AM
Hi All,

I have this code. I am getting an error on highlighted line.

Please help!!!

--------------------------
Sub asdf()
Dim f As Workbook
FolderPaths = "C:\Users\swaminathann\Desktop\Excel"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.GetFolder(FolderPaths)
For Each Workbook In oFolder.Files
If InStr(1, f.Name, "Australia") > 0 Then
Workbooks.Open f.Name
End If
Next Workbook
End Sub

Thanks and Regards,
Swaminathan N