Creating a combo box listing

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I have a list of dates from 01/01/2011 to 31/12/2011 from which I have created 2 lists using Data|Validation and selecting List and using the dates above which are on the same sheet.

What I would like to do is when the user selects say, 01/08/2011 from the first list, I want the data in the second list to begin from 01/08/2011 and not 01/01/2011 as it does currently.

In short is there an event that is triggered when I select the data from the first list (cell A1) that will change the date list on the second list (cell A2)?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this:-
Based on Range of dates in column "A".
Validation list in "B1". set up for dates from column "A".(A1:A365)
Place this code in your sheet.
When you select a Date from "B1" (Say 1/5/2011) then a New validation Box appears in "D1" with dates starting from "1/5/2011".

Code:
[COLOR=navy]Sub[/COLOR] MG29Jun55
Private [COLOR=navy]Sub[/COLOR] Worksheet_Change(ByVal Target [COLOR=navy]As[/COLOR] Range)
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range
[COLOR=navy]Dim[/COLOR] oDys [COLOR=navy]As[/COLOR] [COLOR=navy]Integer[/COLOR]
[COLOR=navy]If[/COLOR] Target.Address(0, 0) = "B1" [COLOR=navy]Then[/COLOR]
    oDys = 365 - DateDiff("d", [b1], "31/12/2011")
    [COLOR=navy]Set[/COLOR] Rng = Range("A" & oDys & ":" & "A365")
    Range("D1").Select
[COLOR=navy]With[/COLOR] Selection.Validation
    .Delete
    .Add Type:=xlValidateList, Formula1:="=" & Rng.Address & ""
[COLOR=navy]End[/COLOR] With
[COLOR=navy]End[/COLOR] [COLOR=navy]If[/COLOR]
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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