Hi Alf
Thanks for that I have tried it a few times to no avail. It seems the
is causing issues. I have tried doing different things but come up with a whole range of different errors.
my code looks like this at the moment
Sub OpenSubfoldersFileUpdate()
Dim strFile As String
Dim objFSO
Dim mainFolder, mySubFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
mFolder = sFolder
Set mainFolder = objFSO.GetFolder(mFolder)
Application.ScreenUpdating = False
For Each mySubFolder In mainFolder.subfolders
strFile = Dir(mySubFolder & "\*.xls*")
Do While strFile <> ""
Workbooks.Open mySubFolder & "\" & strFile
Lastrow = Me.Cells(Me.Rows.Count, "A").End(xlUp).Row + 1
If Lastrow < 4 Then Lastrow = 4
Application.ScreenUpdating = False
Set myrange = Me.Range("D13:D13" & Lastrow)
If Not Intersect(Target, myrange) Is Nothing Then
UpdateFilesInFolder Target, sFolder
End If
Application.ScreenUpdating = True
strFile = Dir
Loop
Next ‘ subfolder
Application.ScreenUpdating = True
End Sub
Sub UpdateFilesInFolder(ByVal Target As Range, ByVal sFolder As String)
Dim strFile As String
strFile = Dir(sFolder & "*.xlsx", vbNormal)
Do While strFile <> ""
If strFile <> ThisWorkbook.Name Then
Set Wb = Workbooks.Open(sFolder & strFile, ReadOnly:=False)
With Wb
.Worksheets("Total Quantities").Range(Target.Address).Value = Target.Value
.Close True
End With
End If
strFile = Dir
Loop
End Sub
I have left it the way you initially wrote it and it highlights that Next ' subfolder line in red indicating an issue. I have removed the apostrophe and tried different lines and altered the code above and below it to try and get it to work but it just keeps kicking back errors.
Bookmarks