vba message box crashes on new entries

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
672
Office Version
  1. 365
Platform
  1. Windows
hi i think this qualifies as a new question

i got help with this message box but it is giving me a run time error and crashes my system
i think the issue is that it isnt allowing a new line entry because immediately it runs the code on the line with the first cell entry
i need that this code should run only if the columns 5 and 6 are filled in with the parameters listed

If Target.Cells.Count = 1 Then

i need to add code here to say only activate code if column A <> "" and columns 5 and 6 have been filled in (really just to activate if column 5 and 6 were filled in with the parameters and ignore all other line entries)

If Target.Column = 5 And Target.Cells.Value = "_Approvals Missing" And Target.Cells.Offset(0, 1).Value <> "" Or _
Target.Column = 6 And Target.Cells.Offset(0, -1).Value = "_Approvals Missing" And Target.Cells.Value <> "" Then

result = MsgBox("pressing OK will send email to notify", vbOKOnly + vbExclamation, "Missing Approval")

If result = vbOK Then

Set OutlookApp = CreateObject("Outlook.Application")
Set OlObjects = OutlookApp.GetNamespace("MAPI")
Set newmsg = OutlookApp.CreateItem(olMailItem)

newmsg.Recipients.Add ("mail@mail.org") ' Add Recipients
newmsg.Subject = "Missing Approval" ' Add Subject
newmsg.Body = "Missing Approval" & vbCrLf & "" & _
"Please get approval for " & _
Cells(Target.Row, "A").Value & _ Will this code use the info filled into column A of the same row
" for Missing Class/Membership: " & _
Target.Cells.Offset(0, 1).Value ' Email Body
newmsg.Display 'Display Email
newmsg.Send 'Send Email

MsgBox "Outlook message sent", , "Outlook message sent" ' Confirm Sent Email


End If
End If
End If


End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
hi
this wasnt my question
i need to tweak my code to only activate after column a is filled in and only if column 6 and 7 are filled in
at the moment as soon as i try to add a new entry it gives a run time error
 
Upvote 0
Is this referring to specific cells in A & F & G ... for example: A1 & F1 & G1 or ....
are you referencing an entire range in each column. Example : A1:A10 & F1:F10 & G1:G10.
 
Upvote 0
hi
i figured it out
this is what i used and the error messages stopped. i hope this is correct:

If Target.Cells.Count = 1 Then
If Cells(Target.Row, "A").Value <> "" And Cells(Target.Row, "E").Value = "_Approvals Missing" And Cells(Target.Row, "F").Value <> "" Or _
Cells(Target.Row, "F").Value <> "" And Cells(Target.Row, "E").Value = "_Approvals Missing" Then
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top