PDA

View Full Version : Combobox with Dynamic Date Range



paul_pearson
07-21-2013, 12:56 PM
Hello All

I need to create a dynamic range for a Combo Box.The dynamic range will be for a series of dates.I need the date sequence to be always 7 days before todays date and 7 days after todays date.eg...using todays date as 21/7/2013 the list dates will start with 14/7/2013 and end with 28/7/2013...it will also need to update daily so as there is always 7 days before and after todays date

If this is possible a excel file of how to achieve could it be posted please

Best Regards

Paul

Admin
07-21-2013, 02:33 PM
Hi Paul

Please find attached the workbook. I hope this will find useful.

paul_pearson
07-21-2013, 03:39 PM
Hi Admin

Yes that is very helpful.Thank you

I tried to add your code to my sheet but it gives me errors. I think it is to do with Combobox versus checkbox...I changed but still gives me errors.

I will want to add more lists to the other combobox on the form,,,,do I just add all the code in the userform code window

What will I need to change to have your date sequence in the combobox for dates

RegardsPaul

Admin
07-21-2013, 04:29 PM
Hi

You only need the userform initialize code.

paul_pearson
07-21-2013, 05:08 PM
Thanks Admin...yes got it to know work...playing around with the code so as to learn for the rest of the userform

My only other question I have is if I change the dates to a different numbered Combobox do I just change this line in the code



With Me.ComboBox1


Example:So if I want the dates to appear in the combobox3 on my userform I change the code above from combobox1 to combobox3..The reason I ask is I have tried but it failed.I am learning as I go but I am changing the code as I think to work

Paul

Admin
07-21-2013, 06:14 PM
If you have multiple comboboxes, you can try


With Me
With .ComboBox1
.List = d
.ListIndex = -1
End With
With .ComboBox3
.List = d
.ListIndex = -1
End With
End With