VBA Message Box Worksheet Change

Copper Contributor
Hi Group..  I want to create a VBA Script that will return a Message Box of: " Employee is Not Eligible for New York State Paid Leave" if the following criteria is met:
 
If cell E19 = "CEO","Founder"
If Cell I15 = "New York State Family Leave"
 
Cell "E19" is a Xlookup Function; Cell "I15" is a Data - Dat Validation - Function
 
I am using a Windows 10 Pro , Microsoft 365 Excel Desktop Application
 
 
 
Thank-you for your help in this matter
10 Replies
first off, your link is to a shared FOLDER and I just guessed the file name as "VBA Question 2" because it was new. Not sure if you care to share all those files but you should either share the file or tell us which file to look at :)
That said, I first offer an easier and possibly better solution. In that file I created a simple IF statement to do what you want (cell G20) added with some conditional formatting to make it stand out and very clear notification. The reason I recommend this is that if they open the file online macros don't work, they also don't work if they have security settings at high or medium and decline letting them run. So this solution work in all cases and you can even lock the sheet (obviously unlock the cells they need to use/enter info into, which has to be done in the desktop version but works online) to prevent them from accidentally deleting that cell or hiding that row.
Thank-you for your tip regarding sharing OneDrive Folders/ Files....I really appreciate that information.
I like the If Statement that you presented, however I would still like to use a VBA Script to have a Pop up option.

Again .. Thank-you for your time!!
Regards!!

@WARJAMAND 

 

Perhaps this is what you're trying to do? I named the employee name, position/title, and primary leave cells (so vba can still find those cells if you insert/delete rows by they name instead of their cell address). If either the employee name cell changes or the primary leave cell changes, then it should test for "ceo" or "founder" and "new york paid family leave". 

 

If you right click on the worksheet and select 'view code' then you'll see the vba procedure. Also, in the attached workbook, note I changed cell E19 to index/match as I don't have xlookup on this machine in order to test it.

Thank-You....I will check out and review once I get home. I really appreciate your time in helping me with this as VBA is not one of my strengths with Excel :grinning_face:
if you want, it could be a hybrid solution that uses the IF() statement with conditional formatting AND the VBA macro so that if they have macros off or view the file online, they still get a notification.

@WARJAMAND 

 

You're quite welcome. In addition to @mtarler 's suggestions, I think another possible non-vba approach you could consider would be to use the filter function to filter out 'new york paid family leave' for ceos or founders so it's not even an option and use that as the data validation source for primary leave, But, you'd also have to apply data validation to the employee name so if primary leave was filled out first or left over from a previous input, it would force them to clear the primary leave field before selecting a ceo or founder.

 

 

Thank-you so much....I use conditional formatting on another tab. I thought I saw a YouTube video stating conditional formatting slows down Excel.

Much appreciated & thank-you again!

WARJAMAND
That is another Great Idea... Thank you again. I will look into this now.

Regards,
WARJAMAND
conditional formatting is another process excel must do so if you have a conditional formatting applied to 10,000 rows of data, yeah you might want to consider that. I really don't think you have anything to worry about in this case.
You Are The Best!!

Regards,WARJAMAND