+ Reply to Thread
Results 1 to 2 of 2

Calculation in User Form

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2011
    Location
    belfast
    MS-Off Ver
    office 365
    Posts
    61

    Calculation in User Form

    Hi All

    I have created a User form with a Date Picker to enable the user to select the date of training I have then a drop down list for validation (i.e. 1 year, 2 years, 3 years & 5 years), what I would like to know if I added a txt box is there any way that once you select a date and the validation it will automatically completed the next txt box with an expiry date


    Date Picker Validation Formula to work out this date in user form
    30/08/2000 2 years 29/08/2002

    Regards

    Malcolm

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Calculation in User Form

    Add a ComboBox to the Form, a DatePicker Control & I would suggest a Label with a white background. Then this code

    Option Explicit
    
    Private Sub ComboBox1_Change()
        Dim dte As Date
        With Me
            dte = .DTPicker1.Value
            dte = DateSerial(Year(dte) + Val(.ComboBox1.Value), Month(dte), Day(dte) - 1)
            .Label1.Caption = ""
            .Label1.Caption = Format(dte, "long date")
        End With
    End Sub
    
    Private Sub UserForm_Initialize()
        Me.ComboBox1.List = Array(1, 2, 3)
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1