ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill values into a listbox matching selected values from a combobox (https://www.excelbanter.com/excel-programming/321564-fill-values-into-listbox-matching-selected-values-combobox.html)

Jon[_19_]

Fill values into a listbox matching selected values from a combobox
 

Hi
I have 2 worksheets (musclegroup and exercise)
I loop in the values from musclegroup into a combobox,
the combobox listindex is the same as the ID(A).

Now I want to fill up the exercises(column B in worksheet exercise) into
the frmExercise.lstExercise
that correspond to the musclegroup I select in frmExercise.cboMusclegroup.

Is there a simply way
Regards
Jon

Follow the link below, explains and shows the userform and worksheets
http://www.johak.se/index.html

Bob Phillips[_6_]

Fill values into a listbox matching selected values from a combobox
 
Jon,

I think this is what you want

Private Sub cboMusclegroup_Click()
frmExercise.lblMuscleGroupID.Caption = frmExercise.cboMusclegroup.ListIndex
'
Dim WS As Worksheet
Dim WSRow As Long
Dim i As Long
'
frmExercise.lstExercise.Clear
'
Set WS = Application.ActiveWorkbook.Worksheets("exercise")
'
'Finds the last row in column B containing a value
WSRow = WS.Cells(Cells.Rows.Count, "B").End(xlUp).Row

Me.lstExercise.Clear
For i = 1 To WSRow
If WS.Cells(i, "C").Value = Me.cboMusclegroup.Value Then
lstExercise.AddItem WS.Cells(i, "B")
End If
Next i
If Me.lstExercise.ListCount 0 Then
Me.lstExercise.ListIndex = 0
End If

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jon" wrote in message
...

Hi
I have 2 worksheets (musclegroup and exercise)
I loop in the values from musclegroup into a combobox,
the combobox listindex is the same as the ID(A).

Now I want to fill up the exercises(column B in worksheet exercise) into
the frmExercise.lstExercise
that correspond to the musclegroup I select in frmExercise.cboMusclegroup.

Is there a simply way
Regards
Jon

Follow the link below, explains and shows the userform and worksheets
http://www.johak.se/index.html




Tom Ogilvy

Fill values into a listbox matching selected values from a combobox
 
Private Sub cboMuscleGroup_Click()
frmExcercise.lstExercise.Clear
for each cell in worksheets("Exercise").Range("A1:A10)
if cell.Value = frmExcercise.cboMuscleGroup.Value then
frmExcercise.lstExercise.AddItem cell.offset(0,1)
end if
Next
End Sub

Assumes A1:B10 is a list with musclegroup in column A and exercise in column
B

--
Regards,
Tom Ogilvy


"Jon" wrote in message
...

Hi
I have 2 worksheets (musclegroup and exercise)
I loop in the values from musclegroup into a combobox,
the combobox listindex is the same as the ID(A).

Now I want to fill up the exercises(column B in worksheet exercise) into
the frmExercise.lstExercise
that correspond to the musclegroup I select in frmExercise.cboMusclegroup.

Is there a simply way
Regards
Jon

Follow the link below, explains and shows the userform and worksheets
http://www.johak.se/index.html




Jon[_19_]

Fill values into a listbox matching selected values from a combobox
 
Jon wrote:

Hi
I have 2 worksheets (musclegroup and exercise)
I loop in the values from musclegroup into a combobox,
the combobox listindex is the same as the ID(A).

Now I want to fill up the exercises(column B in worksheet exercise) into
the frmExercise.lstExercise
that correspond to the musclegroup I select in frmExercise.cboMusclegroup.

Is there a simply way
Regards
Jon

Follow the link below, explains and shows the userform and worksheets
http://www.johak.se/index.html


Thanks Guys
Works perfectly

Tom Ogilvy

Fill values into a listbox matching selected values from a combobox
 
Didn't see your link at the bottom of the message, or mine might have been
more tailored.

--
Regards,
Tom Ogilvy

"Jon" wrote in message
...
Jon wrote:

Hi
I have 2 worksheets (musclegroup and exercise)
I loop in the values from musclegroup into a combobox,
the combobox listindex is the same as the ID(A).

Now I want to fill up the exercises(column B in worksheet exercise) into
the frmExercise.lstExercise
that correspond to the musclegroup I select in

frmExercise.cboMusclegroup.

Is there a simply way
Regards
Jon

Follow the link below, explains and shows the userform and worksheets
http://www.johak.se/index.html


Thanks Guys
Works perfectly





All times are GMT +1. The time now is 09:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com