Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Add values of textboxes together


Hello all

I have a userform that has 5 text boxes on it (Textbox1, Textbox2
etc.) where a user will enter a number in the first 4 boxes. What
would like to happen is in Textbox5 to add the entered numbers from th
first 4 boxes together to give me a total, which will then b
transferred to a spreadsheet(I have that part figured out, just nee
help with the addition part).

Thanks in advance...

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Add values of textboxes together

Candee,

Try something like the following code:

Dim Total As Double
With Me
With .TextBox1
If IsNumeric(.Text) Then
Total = Total + CDbl(.Text)
End If
End With
With .TextBox2
If IsNumeric(.Text) Then
Total = Total + CDbl(.Text)
End If
End With
With .TextBox3
If IsNumeric(.Text) Then
Total = Total + CDbl(.Text)
End If
End With
With .TextBox4
If IsNumeric(.Text) Then
Total = Total + CDbl(.Text)
End If
End With
.TextBox5.Text = Format(Total, "#,##0.00")

Range("A1").Value = Total
End With



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Candee" wrote in message
...

Hello all

I have a userform that has 5 text boxes on it (Textbox1,

Textbox2,
etc.) where a user will enter a number in the first 4 boxes.

What I
would like to happen is in Textbox5 to add the entered numbers

from the
first 4 boxes together to give me a total, which will then be
transferred to a spreadsheet(I have that part figured out, just

need
help with the addition part).

Thanks in advance....


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide

to creating financial statements


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Add values of textboxes together

Candee,

TextBox values are stored as strings.
You need to convert them to actual values before doing any math
with them.

e.g.

TBSum = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value)
MsgBox TBSum

John

Candee wrote:

Hello all

I have a userform that has 5 text boxes on it (Textbox1, Textbox2,
etc.) where a user will enter a number in the first 4 boxes. What I
would like to happen is in Textbox5 to add the entered numbers from the
first 4 boxes together to give me a total, which will then be
transferred to a spreadsheet(I have that part figured out, just need
help with the addition part).

Thanks in advance....

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide to creating financial statements


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Add values of textboxes together


-----Original Message-----

Hello all

I have a userform that has 5 text boxes on it (Textbox1,

Textbox2,
etc.) where a user will enter a number in the first 4

boxes. What I
would like to happen is in Textbox5 to add the entered

numbers from the
first 4 boxes together to give me a total, which will

then be
transferred to a spreadsheet(I have that part figured

out, just need
help with the addition part).

Thanks in advance....


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by

step guide to creating financial statements
.

Added a Linked Cell range to TextBox1-TextBox4 (e.g., A1,
A2, A3, A4). Then add a Linked Cell range to TextBox5
(e.g. A5) that contains the formula =sum(A1:A4)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Add values of textboxes together

Did that work for you? It doesn't work for me. (numbers in the linked cells
are stored as Text so they are ignored by SUM.)

Also, if someone typed in the results textbox (by mistake), it would
overwrite the formula.

xl2000, Windows 2000
--
Regards,
Tom Ogilvy

"Steve Lerner" wrote in message
...

-----Original Message-----

Hello all

I have a userform that has 5 text boxes on it (Textbox1,

Textbox2,
etc.) where a user will enter a number in the first 4

boxes. What I
would like to happen is in Textbox5 to add the entered

numbers from the
first 4 boxes together to give me a total, which will

then be
transferred to a spreadsheet(I have that part figured

out, just need
help with the addition part).

Thanks in advance....


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by

step guide to creating financial statements
.

Added a Linked Cell range to TextBox1-TextBox4 (e.g., A1,
A2, A3, A4). Then add a Linked Cell range to TextBox5
(e.g. A5) that contains the formula =sum(A1:A4)



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
Axes values changes autmatically / textboxes lose formatting Anand Nichkaode Charts and Charting in Excel 5 March 28th 08 04:30 PM
Textboxes SAL Excel Discussion (Misc queries) 2 July 13th 07 12:24 AM
tab between several textboxes Kim Excel Worksheet Functions 0 May 9th 05 04:08 PM
Userfrom textboxes Jo[_6_] Excel Programming 2 October 21st 03 06:56 PM
Userfrom textboxes Jo[_6_] Excel Programming 1 October 21st 03 05:47 PM


All times are GMT +1. The time now is 06:32 AM.

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

About Us

"It's about Microsoft Excel"