I have the following macro below
If I run this macro and select "No" then macro ends
However, if I include this just after the start another macro, then it does not exit when "No" is selected"
It would be appreciated if someone could kindly amend my code, so that when Macro "selectSourceFolder" is selected and message boxcomes yup and "No" is selected" then themacro will exit
If I run this macro and select "No" then macro ends
Code:
Sub Message()
Dim response
response = MsgBox("Have you changed the date in Cell G5?", vbYesNo)
If response = vbNo Then
Exit Sub
Else
End If
End Sub
However, if I include this just after the start another macro, then it does not exit when "No" is selected"
It would be appreciated if someone could kindly amend my code, so that when Macro "selectSourceFolder" is selected and message boxcomes yup and "No" is selected" then themacro will exit
Code:
Sub selectSourceFolder()
Message
ThisWorkbook.Activate 'start in THIS workbook
[sourceFolder].Select 'put cellpointer in tidy location
'**********************************************
'FETCH INPUT FOLDER..
'**********************************************
zFolder = [sourceFolder] 'fetch value from named cell
If zFolder = "" Then 'no default Folder defined yet (or deleted)
zFolder = ThisWorkbook.Path 'use folder location of THIS file
End If 'end of test for no default Folder
If Right(zFolder, 1) <> "\" Then 'check for required last \ in path
zFolder = zFolder & "\" 'add required last \ if missing
End If 'end of test fro required last \ char
[sourceFolder] = zFolder 'refresh initial default folder
On Error Resume Next 'set error trap for next line..
ChDir zFolder 'try and set default folder to cell entry
On Error GoTo 0 'reset error trap
'**********************************************
'FETCH FILE FILTER TYPE..
'**********************************************
zFilesLikeThis = [fileMatchCell] 'fetch from named cell; e.g. "*.xls";"RZ*.*"
If zFilesLikeThis = "" Then 'no file type filter defined
zFilesLikeThis = "*.xls*" 'define file filter as any Excel file
[fileMatchCell] = zFilesLikeThis 'define default file filter
End If
'**********************************************
'DISPLAY FILE SELECTION BOX..
'**********************************************
With Application.FileDialog(msoFileDialogFolderPicker) 'use shortcut
saywhat = "Select the source folder for files to be moved.." 'define browser text
.Title = saywhat 'show heading message for THIS dialog box
.AllowMultiSelect = False 'allow only one file to be selected
.InitialFileName = zFolder 'set default source folder
zItem = .Show 'display the file selection dialog
.InitialFileName = "" 'clear and reset search folder\file filter
If zItem = 0 Then Exit Sub 'User cancelled; 0=no sample file chosen
zFolder = .SelectedItems(1) 'selected folder
End With 'end of shortcut
If Right(zFolder, 1) <> "\" Then 'check for required last \ in path
zFolder = zFolder & "\" 'add required last \ if missing
End If 'end of test fro required last \ char
[sourceFolder] = zFolder 'update named cell with folder path
End Sub