Year get from textbox value in userform

nidhipatel

Board Regular
Joined
Feb 11, 2017
Messages
52
my userform contain 2 textbBox
TextBox1.value = start date
TextBox2.value = end date

e.g
TextBox1.value = 14/8/85
TextBox2.value = 28/10/91

in sheet1 from range "A1" to show start date year to end date year by vba and
using for loop.in above example show result as below

1985
1986
1987
1988
1989
1990
1991
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi
Try this...

Place in UserForm code module
Code:
Private Sub CommandButton1_Click()
    Dim r As Integer, a As Integer
    For a = Year(TextBox1.Value) To Year(TextBox2.Value)
        r = r + 1
        Sheets("Sheet1").Cells(r, 1).Value = a
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,194
Members
453,021
Latest member
pingpong7117

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