I want my macro to continue if the yes no msg box is not triggered. currently i have set a yes no msg box in my macro. for example if the value in cell A1 is more than 100 then the msg box pops up and says "the value is above 100, do you wish to continue?" if i press no it exits sub and if i press yes the rest of the code executes. cool everything works good, but the issue is, when the value in cell A1 is less than 100 and i run the macro, just nothing happens. i want the macro to continue also if the value in cell A1 is below 100. thank you
i am using the following code for msg box
Sub Relieving_Pdf()
Dim AnswerYes As String
Dim AnswerNo As String
Dim StrFolder As String
Dim StrFile As String
Dim Folder As String
Dim StrName As String
Dim StrBack1 As String
Dim StrBack As String
StrFolder = Range("A69").Value 'path
StrFile = Range("B28").Value 'Company Initial Name
Folder = "\" & Range("F1").Text 'Month and year folder name
StrName = "\" & Range("B2").Value 'Candidate name
StrBack1 = Left$(StrFolder, InStrRev(StrFolder, "\") - 1)
StrBack = Left$(StrBack1, InStrRev(StrBack1, "\") - 1)
Application.Run "REFRESH"
If Range("E14").Value = "EID Already Exist" Then
AnswerYes = MsgBox("EID Already Exist Do you want to go ON?", vbQuestion + vbYesNo, "User Repsonse")
If AnswerYes = vbYes Then
If Len(Dir(StrBack & Folder, vbDirectory)) = 0 Then
MkDir(StrBack & Folder)
End If
If Len(Dir(StrBack & Folder & StrName, vbDirectory)) = 0 Then
MkDir(StrBack & Folder & StrName)
End If
ChDir StrFolder
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
StrFolder & "\" & StrFile & " Master Data.xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = True
Dim excelpath As String
Dim wordApp As Object
Set wordApp = CreateObject("Word.Application")
excelpath = ThisWorkbook.FullName
wordApp.Documents.Open Filename:=StrFolder & "\" & StrFile & " Master File Macro.docm"
wordApp.Visible = True
ActiveDocument.MailMerge.OpenDataSource Name:= _
excelpath _
, ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=excelpath;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Engi" _
, SQLStatement:="SELECT * FROM `Output$`", SQLStatement1:="", SubType:= _
wdMergeSubTypeAccess 'enter sheet name
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = 1
.LastRecord = 1
StrName2 = "\" & .DataFields("offername")
StrFolder = StrBack & "\"
End With
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
StrFolder & Folder & StrName & StrName2 & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportFromTo, From:=1, To:=4, Item:= _
wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End With
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
wordApp.Quit
Set wdapp = Nothing
Application.Quit
End If
End If
End Sub
Sub Test()
Const CELL_ADDRESS As String = "E14"
Const COMPARE_STRING As String = "EID Already Exists" ' changed (English)!!!
Const SHOW_COMPARISON_EVALUATION_MESSAGE As Boolean = True
Dim ws As Worksheet: Set ws = ActiveSheet ' improve!
Dim CellString As String: CellString = CStr(ws.Range(CELL_ADDRESS).Value)
' This is a case-insensitive comparison i.e. 'A = a'
Dim AreStringsEqual As Boolean: AreStringsEqual _
= (StrComp(CellString, COMPARE_STRING, vbTextCompare) = 0)
If SHOW_COMPARISON_EVALUATION_MESSAGE Then
MsgBox "The value in cell ""'" & ws.Name & "!'" & CELL_ADDRESS _
& """ of workbook """ & ws.Parent.Name & """ is """ _
& CellString & """." & vbLf _
& "You are comparing it with the given string """ _
& COMPARE_STRING & """." & vbLf & vbLf _
& "The result is that they are """ _
& IIf(AreStringsEqual, "", "NOT ") & "EQUAL""!", _
IIf(AreStringsEqual, vbInformation, vbExclamation), _
"Comparison Evaluation"
End If
Dim Answer As Long ' changed (there's only one)!!!
If AreStringsEqual Then
Answer = MsgBox( _
Prompt:="EID already exists. Do you want to continue?", _
Buttons:=vbQuestion + vbYesNo, _
Title:="User Response")
If Answer = vbNo Then
Exit Sub
End If
End If
MsgBox "Continuing...", vbInformation
' rest of the code
End Sub