OldManDemosthenes
New Member
- Joined
- Apr 19, 2011
- Messages
- 38
I have a multiselect listbox which is populated from "InputData" column D. The "Run" button on my userform must preform 2 tasks.
First is just make a list a of the selection(s) as they appear in column D. This list appears on sheet 1 column A.
Second, I would like to create a string that appears on sheet 1 B1 of all the selected values (selection 1, selection 2, etc..). However, I want the string values to come from "InputData" column E. For example, column D has Chicago, IL but the value in the same row in column E is just Chicago.
So "Run" would theoretically result with sheet 1: A1 as "Chicago, IL", A2 "New York, NY", A3 "San Francisco, CA"; and B1 as "Chicago, New York, San Francisco"
Here is my code so far. Currently I have created the string of results from the values in "InputData" column D not column E
First is just make a list a of the selection(s) as they appear in column D. This list appears on sheet 1 column A.
Second, I would like to create a string that appears on sheet 1 B1 of all the selected values (selection 1, selection 2, etc..). However, I want the string values to come from "InputData" column E. For example, column D has Chicago, IL but the value in the same row in column E is just Chicago.
So "Run" would theoretically result with sheet 1: A1 as "Chicago, IL", A2 "New York, NY", A3 "San Francisco, CA"; and B1 as "Chicago, New York, San Francisco"
Here is my code so far. Currently I have created the string of results from the values in "InputData" column D not column E
Private Sub cbRun_Click()
Dim i As Long, cty As StringWith lbCity.List(i) = ""For i = 0 To .ListCount - 1If .Selected(i) Thencty = cty & .List(i) & ", "End IfNext iEnd With
Cells(1, 2) = ctyUnload MeEnd Sub
Private Sub UserForm_Initialize()
Dim rngCity As RangeWith lbCity.RowSource = ""For Each rngCity In Worksheets("InputData").Range("D2:D" & _Worksheets("InputData").Range("D65536").End(xlUp).Row).AddItem rngCity.ValueNext rngCityEnd SubEnd With