Based on calculation of days then divided by the textbox value 6

hsolanki

Board Regular
Joined
Jan 16, 2020
Messages
204
Office Version
  1. 2010
Platform
  1. Windows
Good Afternoon everybody

I have got a Holiday planner which I managed to find on youtube however I have amended and added a column in C whereby I record each individual holiday entitlement through each year.

when Combobox 1 is selected it shows an employee ID number on textbox 1 and entitlement on textbox 6. and then you can select the 2 dates between and it then it gives you a total number of days however what i would like to achieve is that when the days are calculated and from the combobox2 is selected as "H" it is to calculate the holiday entitlement which is in textbox 6 and the days it is selected to show whether days are within the holiday entitlement and if not it should give a message to say holiday entitlement has been used.

below it is the code where it calculates the days when two dates are selected from the calendar.

i can upload a sample book if anything makes easier

VBA Code:
Sub Calculate_Days()
    Me.lbl_Days.Caption = ""
    
    If Me.TextBox2.Value <> "" And Me.TextBox3.Value <> "" Then
        If CDate(Me.TextBox3.Value) >= CDate(Me.TextBox2.Value) Then
            If Me.ComboBox2.Value = "HDL" Then
                Me.lbl_Days.Caption = Format((CDate(Me.TextBox3.Value) - CDate(Me.TextBox2.Value) + 1) / 2, "0.0") & " day(s)"
            Else
                Me.lbl_Days.Caption = Format(CDate(Me.TextBox3.Value) - CDate(Me.TextBox2.Value) + 1, "0") & " day(s)"
            End If
        End If
    End If
End Sub
 

Attachments

  • holiday planner.png
    holiday planner.png
    56.8 KB · Views: 10

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Found a better solution sorry i was meant to be minus and not divided. i just changed the textbox name to actual textbox and then subtract using the two boxes value and figured it out

VBA Code:
Me.TextBox8 = Me.TextBox6.Value - Me.TextBox7.Value
 
Upvote 0
Solution

Forum statistics

Threads
1,214,917
Messages
6,122,233
Members
449,075
Latest member
staticfluids

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