View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Matt Matt is offline
external usenet poster
 
Posts: 516
Default Excel Script for Drop Down Menu

sorry, i had copied the answer i got yesterday underneath, or so i thought.

the two suggestions below were given. both use the same set of data to
create two different lists. i need two sets of data to create two different
lists. again, i kind of need it spelled out for me. thanks.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim t, List
For t = 18 To 24
If Cells(t, "H") < "" Then List = List & "," & Cells(t, "H")
Next
With Range("H2").Validation
.Delete
.Add xlValidateList, Formula1:=List
.InCellDropdown = True
End With
With Range("H2").Validation '<=== change H4 to the real cell
.Delete
.Add xlValidateList, Formula1:=List
.InCellDropdown = True
End With

'etc.

End Sub

or you could a utility proc


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim t, List
For t = 18 To 24
If Cells(t, "H") < "" Then List = List & "," & Cells(t, "H")
Next

Call SetupDV(Me.Range("H2")
Call SetupDV(Me.Range("H4")
'etc.

End Sub

Private Sub SetupDV(rng As Range)
With rng.Validation
.Delete
.Add xlValidateList, Formula1:=List
.InCellDropdown = True
End With
End Sub


"JE McGimpsey" wrote:

It's hard to help when you say "I don't think it will work", but don't
say why...

Pulling data from "a different place" is certainly possible when the
_SelectionChange event target range is handled serially.


In article ,
Matt wrote:

I don't think either of those things will work because each drop down list
pulls data from a different place. i only have 1 year of C++ as programming
experience and i feel like the solution is possible, but i don't know enough
VB to figure it out. Please help.