dynamically add TextBox value in worksheet

Arie Bos

Board Regular
Joined
Mar 25, 2016
Messages
224
Office Version
  1. 365
Platform
  1. Windows
I have a user form with a textbox. On the same form, I'd like to show the product of the value that is entered in this textbox and another cell value in a Label.
The problem is that the value is only pasted at the cell after pressing a control button to confirm, so the label does not show anything in real time. Is this possible anyway?
I had the following code:

VBA Code:
Private Sub btnNEXT1_Click()
    Sheets("Data").Select
    Range("A" & CStr(Rows.Count)).End(xlUp).Select
    ActiveCell.Offset(2, 0).Value = TextBox1.Value
    Unload Me
    frmSSD.Show vbModeless
End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
How about
VBA Code:
Private Sub TextBox1_Change()
   If Me.TextBox1 <> "" Then
      Me.Label1.Caption = Me.TextBox1.Value * Range("A1").Value
   Else
      Me.Label1.Caption = ""
   End If
End Sub
 
Upvote 0
Solution
Hello Fluff,
Many thanks! I even can show the product of two different textboxes real time.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
BTW, is it possible to add a number format to the result number shown in the Label?
 
Upvote 0
Yup, like
VBA Code:
      Me.Label1.Caption = Format(Me.TextBox1.Value * Range("A1").Value, "#,##0.00")
 
Upvote 0
Working with this solution, is it also possible to add up two values, like:
VBA Code:
Me.Label23.Caption = Format((Me.TextBox2.Value / 12) + (Me.TextBox3.Value / 12), "#,##0")

I get error 13 Type mismatch
 
Upvote 0
That should be fine as long as neither textbox is blank nor contain text.
 
Upvote 0

Forum statistics

Threads
1,213,517
Messages
6,114,085
Members
448,548
Latest member
harryls

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