Avatar of gdunn59
gdunn59 asked on

How can I exclude a range of cells from having the MsgBox warning pop-up

I have the following vba code in excel that pops up a warning msgbox if a user tries to enter data in these 2 cells (Columns L & M) and there is nothing populated in another Column.  The problem is the msgbox should only pop up if the user is selecting one of the 2 columns (L & M) starting on Row 8 and below.

Code:
If Target.CountLarge > 1 Then Exit Sub

If Target.Column = 12 Or Target.Column = 13 And Target.Row > 7 Then
   If Cells(Target.Row, "F") = "" Then
      MsgBox "You cannot update SubmittedDate or Comments2 because this Invoice has not had an eBill file generated yet.", vbExclamation, "InvElecHistoryID Missing!"
'      Cells(Target.Row, "F").Select
   End If
End If

Open in new window


How does the code need to be changed to adapt to this?

Thanks,

gdunn59
VBAMicrosoft Excel

Avatar of undefined
Last Comment
gdunn59

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Doug

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
gdunn59

Doug,

That's what I have other than I don't have the parenthesis.  That makes a difference?

Thanks,

gdunn59
ASKER
gdunn59

Doug,

I tried your solution and it did work.  Wow I did not know that by just adding the parenthesis that it would work, and that it was such a simple fix.

Thanks much,

gdunn59
Doug

Yes.  The parens result in a single TRUE or FALSE for the check on the column and that, coupled with the check on the row should give you the result that you're looking for.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Doug

Happy to help.
ASKER
gdunn59

Worked like a charm.  Thanks!!!!!