View Full Version : VBA an MSGBOX
bloodmilksky
12-14-2016, 06:49 AM
Hi Guys, I hope you are all well.
I was just wondering if anyone could help. I have a holiday form that has Remaing Holidays in B12, Holidays Taken In B13 and requested in E21. What I was wondering if anyone knows how I would have a MSGBOX pop up
If B13 EXCEEDS 25 Days
If B12 & E21 EXCEED 25
Any Help would be greatly appreciated
Many thanks
Jamie
Paul_Hossler
12-14-2016, 07:20 AM
When do you want it to pop up?
Whenever B13 or E21 change?
bloodmilksky
12-14-2016, 07:31 AM
basically if B13 exceeds 25 or if the total of B12 & E22 exceed 25
CROSS-POSTED: http://www.mrexcel.com/forum/excel-questions/980746-visual-basic-applications-if-statements.html
Paul_Hossler
12-14-2016, 01:49 PM
basically if B13 exceeds 25 or if the total of B12 & E22 exceed 25
Yes, that's what you said, but what event do you want to use to have the MsgBox pop up?
I'm guessing that you want to trigger (and test) on changes to the 3 cells
Put this in the code module for the worksheet, and fix as necessary
Option Explicit
'If B13 EXCEEDS 25 Days
'If B12 & E21 EXCEED 25
'I have a holiday form that has Remaing Holidays in B12, Holidays Taken In B13 and requested in E21
'Basically if B13 exceeds 25 or if the total of B12 & E22 exceed 25
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address(False, False)
Case "B12", "B13", "E21"
If Range("B12").Value + Range("E21").Value > 25 Then
MsgBox "Remaining + Requested > 25"
ElseIf Range("B13").Value > 25 Then
MsgBox "Taken > 25"
End If
End Select
End Sub
PS: http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.