Hi,
In Sheet1 there are some columns.
Column A (Date_Begin) and column B (Date_end) has date format.
I want to populate ComboBox1 with nummber 0f years from column A and column B.
I am thinking to find the lowest year (“yyyy”) from column A and the highest year from column B.
Here is some data.
The lowest year in column A is = 2015
The heist year in column B is =2021
The number of years between the lowest and the heist is 6 year.
So lowest year + 1, lowest year + 2, , , , , , lowest year +6.
The result of ComboBox1 should be like this (show only "yyyy"):
2015
2016
2017
2018
2019
2020
2021
Help with this please.
In Sheet1 there are some columns.
Column A (Date_Begin) and column B (Date_end) has date format.
I want to populate ComboBox1 with nummber 0f years from column A and column B.
I am thinking to find the lowest year (“yyyy”) from column A and the highest year from column B.
Here is some data.
Date_Begin | Date_end |
2015-01-01 | 2016-12-31 |
2015-01-01 | 2017-12-31 |
2018-10-01 | 2018-12-30 |
2018-01-01 | 2019-12-31 |
2019-01-01 | 2021-05-30 |
The lowest year in column A is = 2015
The heist year in column B is =2021
The number of years between the lowest and the heist is 6 year.
So lowest year + 1, lowest year + 2, , , , , , lowest year +6.
The result of ComboBox1 should be like this (show only "yyyy"):
2015
2016
2017
2018
2019
2020
2021
Help with this please.
Code:
Private Sub UserForm_Initialize()
'
Dim i As Integer
Dim LowestYear As Long
Dim HeistYear As Long
Dim TotYears As Long
LowestYear = Min(Range("A2", .Range("A" & Rows.Count).End(xlUp)))
HeistYear = Max(Range("B2", .Range("B" & Rows.Count).End(xlUp)))
TotYears = HeistYear - LowestYear
For i = 1 To TotYears
'
'
' add to ComboBox
'
Next
End Sub