Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Adding up values of textbox in Userform

I am using Excel 97.
I want a userform with textboxes. One of the textboxes
will display the sum of the other textboxes, if the
values of the textboxes are changed the sum textbox
changes.

On clicking a button the values are transposed onto a
worksheet.

Thanks

Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Adding up values of textbox in Userform

Something like

Private Sub TextBox1_Change()

TexBox5.Text = TextBox1.Text + _
TextBox2.Text + _
TextBox3.Text + _
TextBox4.Text +
End Sub

etc.

Private Sub CommandButton1_Click()
With Worksheets("Sheet1).
.Range("A1").Value = TextBox1.Text
.Range("B1").Value = TextBox2.Text
.Range("C1").Value = TextBox3.Text
.Range("D1").Value = TextBox4.Text
.Range("E1").Value = TextBox5.Text
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
I am using Excel 97.
I want a userform with textboxes. One of the textboxes
will display the sum of the other textboxes, if the
values of the textboxes are changed the sum textbox
changes.

On clicking a button the values are transposed onto a
worksheet.

Thanks

Mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding up values of textbox in Userform

Mark,

Here is what I came up with.

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim i As Long
Dim myrng As Range
Worksheets("sheet1").Activate
Set myrng = Worksheets("sheet1").Cells(1, 1).CurrentRegion
For i = 1 To myrng.Rows.Count
Next i
With UserForm1
myrng(i, 1).Value = .TextBox3.Text
End With
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer) 'tab key
Application.ScreenUpdating = False
Dim tb1 As Long
Dim tb2 As Long
If KeyCode = "9" Or KeyCode = "13" Then
tb1 = TextBox1
tb2 = TextBox2
With UserForm1
.TextBox3.Value = tb1 + tb2
End With
End If
End Sub

Every time you tab or hit the enter key on textbox2 the value o
textbox3 changes.
Click the commandbutton and it put texbox3 to the worksheet.

HTH

Charle

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Adding up values of textbox in Userform

Hi Mark

You must use this to make a value of the textbox text if you
want to sum them

TextBox5.Text = CDbl(TextBox1.Text) + _
CDbl(TextBox2.Text) + _
CDbl(TextBox3.Text) + _
CDbl(TextBox4.Text)


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Bob Phillips" wrote in message ...
Something like

Private Sub TextBox1_Change()

TexBox5.Text = TextBox1.Text + _
TextBox2.Text + _
TextBox3.Text + _
TextBox4.Text +
End Sub

etc.

Private Sub CommandButton1_Click()
With Worksheets("Sheet1).
.Range("A1").Value = TextBox1.Text
.Range("B1").Value = TextBox2.Text
.Range("C1").Value = TextBox3.Text
.Range("D1").Value = TextBox4.Text
.Range("E1").Value = TextBox5.Text
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Mark" wrote in message
...
I am using Excel 97.
I want a userform with textboxes. One of the textboxes
will display the sum of the other textboxes, if the
values of the textboxes are changed the sum textbox
changes.

On clicking a button the values are transposed onto a
worksheet.

Thanks

Mark





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WordWrap a TextBox on a UserForm dcornett63 Excel Discussion (Misc queries) 2 April 22nd 10 09:35 PM
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
Textbox in userform shaharul[_6_] Excel Programming 3 April 15th 04 12:54 PM
hide a textbox on a userform? Bill Lunney Excel Programming 2 July 31st 03 08:57 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 09:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"