Load several data rows in excel from UserForm.

MRVERD

New Member
Joined
Mar 31, 2014
Messages
1
Hi I am trying to create data base that allow me to load multiple rows of data with ONE click In the user form. I have managed to load data for each record I input,. what I need is to write a code that allow the user form load as ma rows as records selected I the List of Trials, I try to explain that in the picture, I hope this is enough for me to explain, thanks for the help



Here is a picture of the screens.
https://www.dropbox.com/s/pma11g3jcqnik5q/Info Engish.docx?dl=0


here is ink to the file.

https://www.dropbox.com/s/nqr1tb9b7150k0u/TULUM01.xlsm?dl=0
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hey. Welcome to the MessageBoard!

This will help get the values from the listbox and put them on Sheet 1 Col D - F

Code:
[COLOR=#0000ff]Private Sub[/COLOR] cmdloadata_Click()
   
[COLOR=#0000ff]   If[/COLOR] AZTLAN.txtTrialsummary.ListCount <> 0[COLOR=#0000ff] Then[/COLOR]
        [COLOR=#0000ff]For [/COLOR]oItem = 0[COLOR=#0000ff] To[/COLOR] AZTLAN.txtTrialsummary.ListCount - 1
            LR = Sheets(1).Range("D" & Rows.Count).End(xlUp).Row[COLOR=#008000] 'Redefine Last Row[/COLOR]
            [COLOR=#0000ff]If [/COLOR]AZTLAN.txtTrialsummary.Selected(oItem) =[COLOR=#0000ff] True Then[/COLOR]
               [COLOR=#0000ff] Select Case[/COLOR] oItem
              [COLOR=#0000ff]  Case [/COLOR]0
[COLOR=#008000]                'All Items are selected ---> H3:J8[/COLOR]
                  [COLOR=#0000ff]  For[/COLOR] x = 3[COLOR=#0000ff] To[/COLOR] 9
                        [COLOR=#0000ff]For[/COLOR] b = 8 [COLOR=#0000ff]To[/COLOR] 10
                            Sheets(1).Cells(LR + x - 2, b - 4) = Sheets(2).Cells(x, b)
                       [COLOR=#0000ff] Next [/COLOR]b
                  [COLOR=#0000ff]  Next[/COLOR] x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
             [COLOR=#0000ff]   Case [/COLOR]1
[COLOR=#008000]                'Data Corresponds To H3:J3[/COLOR]
                    For x = 8 To 10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(3, x)
                 [COLOR=#0000ff]   Next [/COLOR]x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
              [COLOR=#0000ff]  Case [/COLOR]2
[COLOR=#008000]                 'Data Corresponds To H4:J4[/COLOR]
                  [COLOR=#0000ff]  For[/COLOR] x = 8 [COLOR=#0000ff]To[/COLOR] 10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(4, x)
                   [COLOR=#0000ff] Next [/COLOR]x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
            [COLOR=#0000ff]    Case[/COLOR] 3
[COLOR=#008000]                 'Data Corresponds To H5:J5[/COLOR]
                  [COLOR=#0000ff]  For[/COLOR] x = 8 [COLOR=#0000ff]To[/COLOR] 10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(5, x)
                    [COLOR=#0000ff]Next [/COLOR]x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
               [COLOR=#0000ff] Case[/COLOR] 4
[COLOR=#008000]                 'Data Corresponds To H6:J6[/COLOR]
                 [COLOR=#0000ff]   For [/COLOR]x = 8 [COLOR=#0000ff]To [/COLOR]10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(6, x)
                   [COLOR=#0000ff] Next [/COLOR]x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
                [COLOR=#0000ff]Case[/COLOR] 5
[COLOR=#008000]                 'Data Corresponds To H7:J7[/COLOR]
                [COLOR=#0000ff]    For[/COLOR] x = 8 [COLOR=#0000ff]To[/COLOR] 10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(7, x)
                  [COLOR=#0000ff]  Next [/COLOR]x
       [COLOR=#008000]             'Code To insert All of the other ComboBox Values Her[/COLOR]e
               [COLOR=#0000ff] Case [/COLOR]6
[COLOR=#008000]                 'Data Corresponds To H8:J8[/COLOR]
                  [COLOR=#0000ff]  For[/COLOR] x = 8 [COLOR=#0000ff]To[/COLOR] 10
                           Sheets(1).Cells(LR + 1, x - 4) = Sheets(2).Cells(8, x)
                   [COLOR=#0000ff] Next[/COLOR] x
[COLOR=#008000]                    'Code To insert All of the other ComboBox Values Here[/COLOR]
[COLOR=#0000ff]                End Select[/COLOR]

[COLOR=#0000ff]            End If[/COLOR]
      [COLOR=#0000ff]  Next [/COLOR]oItem
[COLOR=#0000ff]    Else[/COLOR]
[COLOR=#008000]    'Do Nothing[/COLOR]
[COLOR=#0000ff]    End If[/COLOR]
    Unload Me
[COLOR=#0000ff]End Sub[/COLOR]

The listbox is the tricky part. You should be able to build on this code to insert the other combobox values....
 
Upvote 0

Forum statistics

Threads
1,215,412
Messages
6,124,761
Members
449,187
Latest member
hermansoa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top