Hi
I have a macro that populates a word document template from a table in excel. Users press a report generator button and it creates the file.
However, for the cases as shown below where the user selects "compliance", "scope", or "vendor" in a specific cell i want the code to return a message box and not proceed further to generate the file. When i run this code below, it keeps creating the file. Can somone please tell me what I'm doing wrong with the IF statement.
Thanks,
I have a macro that populates a word document template from a table in excel. Users press a report generator button and it creates the file.
However, for the cases as shown below where the user selects "compliance", "scope", or "vendor" in a specific cell i want the code to return a message box and not proceed further to generate the file. When i run this code below, it keeps creating the file. Can somone please tell me what I'm doing wrong with the IF statement.
Thanks,
Code:
Private Sub GenerateReport_Click()
Dim ws As Worksheet
Dim btmrow As Integer
Set ws = ThisWorkbook.Sheets("Register")
'define btmrow (bottom row)
btmrow = Cells(Rows.Count, "A").End(xlUp).Row
'IF statement for jobs that should not produce a report
If ws.Cells(btmrow, 8).Value = "Compliance" Then
MsgBox ("No report generated for compliance NDT")
ElseIf ws.Cells(btmrow, 8).Value = "Scope" Then
MsgBox ("No report generated for compliance Scope")
ElseIf ws.Cells(btmrow, 8).Value = "Vendor" Then
MsgBox ("No report generated for vendor Scope")
Exit Sub
Else
'Create new file....