Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populating a combobox within a form with concatenated data
Hi Everyone,
I am by no means an expert on VBA programming and was hoping someone could help me out (am desperate!). Is there any way to populate a ComboBox within a form with concatenated data? I am able to concatenate data on a worksheet, but can't figure out how to incorporate this function within a form. With prior assistance, I was able to populate a ComboBox with "regular" worksheet data using the following code: --------------------------------------------------------------------------------- Private Sub UserForm7Combobox1_Initialize() Dim i As Long Dim S1 As Worksheet Set S1 = Worksheets("DataEntry") For i = 2 To S1.Range("A2").End(xlDown).Row UserForm7.ComboBox1.AddItem S1.Cells(i, 1).Value Next i End Sub ----------------------------------------------------------------------------------- As written, the data in column "A" are just last names. I would like to join that info with three other non-consecutive columns of data (columns A,B,C,F) using a For/Next loop, like the one above. If I were to do this on a worksheet (which I can't with this project) it would look something like this: =concatenate (A2, ", " , B2, C2, ". " , F2) The first value returned in worksheet column "BD" would be equal to: Neuman, Alfred E. 123456789 I would like to populate my ComboBox (using the above coding ) with the concatenated data in column "BD" rather than column "A". My main question is: can I just insert a single line of code to concatenate my data into the above subroutine? If so, what would be the correct syntax? If I can get this figured out, the rest of my project will be a piece of cake. Otherwise, I'm screwed! Thank you for your time, Jeff |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populating a combobox within a form with concatenated data
edit
UserForm7.ComboBox1.AddItem S1.Cells(i, 1).Value to look like this UserForm7.ComboBox1.AddItem S1.Cells(i, 1) + ","+s1.cells(i,2)+s1.cells(i,3)+"," + s1.cells(i,6) -- When you lose your mind, you free your life. " wrote: Hi Everyone, I am by no means an expert on VBA programming and was hoping someone could help me out (am desperate!). Is there any way to populate a ComboBox within a form with concatenated data? I am able to concatenate data on a worksheet, but can't figure out how to incorporate this function within a form. With prior assistance, I was able to populate a ComboBox with "regular" worksheet data using the following code: --------------------------------------------------------------------------------- Private Sub UserForm7Combobox1_Initialize() Dim i As Long Dim S1 As Worksheet Set S1 = Worksheets("DataEntry") For i = 2 To S1.Range("A2").End(xlDown).Row UserForm7.ComboBox1.AddItem S1.Cells(i, 1).Value Next i End Sub ----------------------------------------------------------------------------------- As written, the data in column "A" are just last names. I would like to join that info with three other non-consecutive columns of data (columns A,B,C,F) using a For/Next loop, like the one above. If I were to do this on a worksheet (which I can't with this project) it would look something like this: =concatenate (A2, ", " , B2, C2, ". " , F2) The first value returned in worksheet column "BD" would be equal to: Neuman, Alfred E. 123456789 I would like to populate my ComboBox (using the above coding ) with the concatenated data in column "BD" rather than column "A". My main question is: can I just insert a single line of code to concatenate my data into the above subroutine? If so, what would be the correct syntax? If I can get this figured out, the rest of my project will be a piece of cake. Otherwise, I'm screwed! Thank you for your time, Jeff |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Populating a combobox within a form with concatenated data
You're AWESOME!!!
Thanks Ben! Jeff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ComboBox populating problem | Excel Programming | |||
Populating a ComboBox | Excel Programming | |||
Populating ComboBox Methods | Excel Programming | |||
Populating Combobox Methods | Excel Programming | |||
populating a combobox on a worksheet | Excel Programming |