Hi everyone I have the below macro that needs help checking if the file to open is opens or not, if it does not then needs to skip to the else.
Thanks anyone for any help.
Thanks anyone for any help.
Code:
Sub Place_Path()
Dim wb As Workbook
ThisFile = Worksheets("MyStoreInfo").Range("C2")
Area = Worksheets("MyStoreInfo").Range("E8")
Region = Worksheets("MyStoreInfo").Range("F8")
District = Worksheets("MyStoreInfo").Range("C8")
M0nth = Worksheets("Schedule Dashboard").Range("F3")
fPath = ("[URL]http://abcdefg/[/URL]" & Area & "/" & Region & "/" & District & "/" & M0nth & "Schedule" & ThisFile & ".xlsx")
sstring = Replace(fPath, " ", "%20")
Sheets("MyStoreInfo").Range("G2") = sstring
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Workbooks.Open(Filename:=sstring)
'Here i need to create something here that tries to open the above "sstring", If it does not exist then the "Else" statement below
For Each wb In Application.Workbooks ' Loop through each workbook
If wb.Name <> ThisWorkbook.Name Then ' Exclude this workbook
For Each ws In wb.Sheets ' Loop through each worksheet of each workbook
If ws.Name = "Week 1" Then
Sheets("Week 1").Select
Sheets("Week 1").Range("AT1").Copy
ThisWorkbook.Activate
Sheets("Schedule Dashboard").Select
Range("W11").Select
ActiveSheet.Paste
End If
Next ws
End If
Next wb
'Else Sheets("Schedule Dashboard").Range("W11") = "have not"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: