good evening..i would like to ask how to combine all different if statement in only one message box...for an example:
Private Sub CommandButton1_Click() Set a = Sheets("License").Cells(9, 10) Set b = Sheets("License").Cells(10, 10) Set c = Sheets("License").Cells(11, 10)
If a = "Overdue" Then MsgBox ("Update " & Cells(9, 2) & " driving licence before " & Cells(9, 8)) End If
If c = "Overdue" Then MsgBox ("Update " & Cells(11, 2) & " driving licence before " & Cells(11, 8)) End If
If b = "Overdue" Then MsgBox ("Update " & Cells(10, 2) & " driving licence before " & Cells(10, 8)) End If End sub
dim strMsg as String strMsg = "" If a = "Overdue" Then
strMsg = strMsg & vbcrlf & vbcrlf & "Update " & Cells(9, 2) & " driving licence before " & Cells(9, 8)
End If
If c = "Overdue" Then
strMsg = strMsg & vbcrlf & vbcrlf & "Update " & Cells(11, 2) & " driving licence before " & Cells(11, 8)
End If
If b = "Overdue" Then
strMsg = strMsg & vbcrlf & vbcrlf & "Update " & Cells(10, 2) & " driving licence before " & Cells(10, 8)
End If
if strMsg <> "" then
MsgBox strMsg
endif End sub
Advertisement