Hi everyone,
I have created a macro that should go through each row of a worksheet and look at two columns for specific values. If these values are in a row, a message box should appear asking to confirm that these details are true. If you click yes, the macro will continue, if you press no, the workbook will close without saving. I am getting an error when I run this macro and I am not sure why, can someone help?
I have created a macro that should go through each row of a worksheet and look at two columns for specific values. If these values are in a row, a message box should appear asking to confirm that these details are true. If you click yes, the macro will continue, if you press no, the workbook will close without saving. I am getting an error when I run this macro and I am not sure why, can someone help?
Code:
Dim x As String
Dim y As String
Dim i As Integer
Dim found As Boolean
Dim Message As String
Sheet1.Select
Range("A1").Select
x = "CIBC"
y = "FRN"
found = False
i = 1
Do Until IsEmpty(ActiveCell)
If Cells(i, 4).Value = x And Cells(i, 6).Value = y Then
found = True
If found = True Then
Message = MsgBox("Please confirm that the CUID for broker: " & Cells(i, 4) & " and product: " & Cells(i, 21) & " is " & Cells(i, 19), vbYesNo, "CIBC FRN")
If Message = vbNo Then
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
Else
End If
End If
End If
i = i + 1
Loop