Hello, everyone,
I realize that the question is frequently ask but I could not find any solution that worked for me.
I have a word document where I am creating a macro in order to generate standard report using a template and some data entered by users. I need to have a combobox on my form and four text boxes associated with it so that the users select values from the list, and the text boxes are filled automatically but can be edited. The data source is an Excel worksheet.
I would also like the users to have an opportunity to add new rows in the datasource entering it in the form (and maybe using some special button).
I'll be extremely grateful for any help
Last edited by Freaky_zoid; 04-02-2009 at 08:06 AM.
Trapped like a tiger in a washing machine
You can add a new row by this code:
Code:Private Sub CommandButton1_Click() Lastrow = Range("A65536").End(xlUp).Row Rows("" & Lastrow & ":" & Lastrow & "").Select Selection.Insert Shift:=xlDown End Sub
ExlGuru
Hi, ExlGuru,
Thank you for the help. I managed to make a list of my items from the excel file, but when I open the userform there is a value selected in the combobox, and it is always the one in the fourth row. I can change it but I wonder how to make the box appear blank until a select any item from the list.
combobox.Clear didn't help me. I also didn't find the fourth row (or third list item)mentioned anywhere in the code.
And the button for inserting new rows doesn't work for some reason... the ".Insert" is hihglighted and the message says "Method or data member not found"
Trapped like a tiger in a washing machine
Typically after the ComboBox is bound you can add something as simple as:
which will be selected intially.Code:comboBox1.Items.Insert(0, new ListItem("Select",string.Empty));
ExlGuru
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks