VBA and IF Statements

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
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 or
  • If B12 & E21 EXCEED 25

Any Help would be greatly appreciated

Many thanks

Jamie
 
so

C12 Would be 1.5 (1 and a half days)
E21 Would Be 1.5 (days Requested)
C13 Would Be 28.5

all of the named ranges are on the same sheet.
 
Upvote 0
it keeps on saying that the there isnt enough holiday when the sum doesnt add up to 25. Could I ask for a bit of help?
Well, based on your example, that would be correct.

Looking at your first two lines of code:
Code:
    If Range("C12").Value - Range("E21").Value < 25 Then
        Msg = " You Dont Have Enough Holiday " & Application.UserName & " Would You Like To Continue ? "
and based on your example, you would have 1.5-1.5 which equals 0, which is less than 25.

So, according to the condition you set up, it SHOULD tell you that you don't have enough Holiday. So that part of the code appears to be working as designed.
Do you want some other sort of logic there?
 
Upvote 0
I am wondering if i am looking at this Wrong and getting it to check too much?

I was looking at the sums yesterday thinking they where wrong.
 
Upvote 0

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