View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default start value in a combobox

I'm kind of confused at the ranges and worksheet names, but maybe something like
this will get you started:

Option Explicit
Dim myRng As Range
Private Sub ComboBox1_Change()
With Me.ComboBox1
If .ListIndex = myRng.Cells.Count - 1 Then
Me.ComboBox2.RowSource = ""
Me.ComboBox2.AddItem "Nothing to pick!"
Else
Me.ComboBox2.RowSource _
= myRng.Resize(myRng.Rows.Count - .ListIndex + 1, 1) _
.Offset(.ListIndex + 1, 0).Address(external:=True)
End If
End With
End Sub
Private Sub UserForm_Initialize()

Set myRng = Worksheets("sheet1").Range("a1:a10")

With Me.ComboBox1
.Style = fmStyleDropDownList
.RowSource = myRng.Address(external:=True)
End With

End Sub




Alvin Hansen wrote:

Hi
i have this in a userform . combobox
Dim myrange3 As Range
On Error Resume Next

Set myrange3 =
Sheets(Range("kurt!$h$1").Value).Range(Range("kurt !$h$1").Value)
On Error GoTo 0
If myrange3 Is Nothing Then
MsgBox ("Ingen mapper i Gruppen")
Exit Sub
End If
For Each c In myrange3
kursist2.AddItem c.Text

Next
The same code is in another combobox and the get the same value but can't i
say that the second combobox shall start in the range after the first
combobox choice.

Maybe this is better
RAnge = 1-2-3-4-5-6-7-8-9-10 ..............
I make my choice in combobox1 and take 5 as value
Then i want my second combobox to start at 6 not again from 1
Can i do that?

Regards
alvin


--

Dave Peterson