Userform to enter values and shown in same userform in list

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
hi there

i have a Userform to enter values .......................

I need the same userform to show the entered values in list form ? How can i do this ????????

:(
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Andywiz

Board Regular
Joined
May 25, 2005
Messages
238
Hesham,

You could use a label on the useform to capture the values entered. Here is an example of what I mean...

On a userform there is:

1. TextBox1 - used to capture inputs from the user;
2. Label1 - used to display the inputs in a list;
3. CommandButton1 - used to 'submit' the entries to the list.

If you add the following code to CommandButton1, the entries will be recorded sequentially within the Label:

Code:
Private Sub CommandButton1_Click()

If Label1.Caption = "" Then

Label1.Caption = TextBox1.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & TextBox1.Value

End If

TextBox1.Value = ""

End Sub

Hope this helps you reach your aim, come back if you want help customising it to suit your userform.

Andywiz
 

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
Thank u very much (y)

It worked and got the idea...............

How can i sum the values entered when they appear under the Label ?

So i can show the summation in a TextBox ?
 

Andywiz

Board Regular
Joined
May 25, 2005
Messages
238
I guess you could try creating another textbox - say TextBox2 - to contain the total of the inputs going into the label. Then, if you were to try this new code, TextBox2 should show the running total as inputs to the label are added...

Code:
Private Sub CommandButton1_Click() 

If Label1.Caption = "" Then 

Label1.Caption = TextBox1.Value
TextBox2.Value = TextBox1.Value

Else: 
Label1.Caption = Label1.Caption & vbCr 
Label1.Caption = Label1.Caption & TextBox1.Value 
TextBox2.Value = TextBox2.Value + TextBox1.Value

End If 

TextBox1.Value = "" 

End Sub

I think you may run into difficulty if the entries to textbox1 are not numeric though - I haven't tested it I'm afraid.

Good luck with it,
Andywiz :eek:
 

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
Thank u 4 reply, but this line
Code:
TextBox2.Value = TextBox2.Value + TextBox1.Value
put the numeric values next to each other

i need to sum them insted ?
 

Andywiz

Board Regular
Joined
May 25, 2005
Messages
238
OK,

You can replace the line that's causing errors with:

Code:
TextBox2.Value = WorksheetFunction.Sum(TextBox2.Value, TextBox1.Value)

Hope it works for you now.
Cheers.
Andywiz
 

Watch MrExcel Video

Forum statistics

Threads
1,118,167
Messages
5,570,639
Members
412,334
Latest member
ExcelForLifeDontHate
Top