Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jamal,
You can use conversion functions to convert the text strings into numeric values. Here's an example that will work (assuming your "total" TextBox is named "TextBox4"): Private Sub CommandButton1_Click() Dim dblTotal As Double Dim ctl As Control For Each ctl In Controls If TypeOf ctl Is MSForms.TextBox Then If ctl.Name < "TextBox4" Then If IsNumeric(ctl.Object.Text) Then dblTotal = dblTotal + _ CDbl(ctl.Object.Text) End If End If End If Next ctl TextBox4.Text = Format$(dblTotal, "#,##0.00") End Sub This will add up all values in TextBoxes on the Userform. It ignores non-numeric values. -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] Jamal wrote: I was following a question, which was posted to this group about two weeks ago on summing up the values of text boxes into another text box. I tried the following: TextboxTotal = T1+T2+T3 'T being the textboxes instead of adding the numerical values it just places them side by side. So the contents of Textboxtotal becomes 100200300 instead of 600. However when i did the following it works: TextboxTotal = (T1*1)+(T2*1)+(T3*1) it seems the contents of each box is not being treated as numbers. I am using Excel 2000 Is this a bug or I am missing something? Thanks. It is just bugging me. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Default font for pasted text in text boxes - Excel 2007 | Excel Discussion (Misc queries) | |||
User Form Text Boxes - Copy format of text boxes | Excel Discussion (Misc queries) | |||
How to Import Visio Text Boxes into Excel as Text | Excel Discussion (Misc queries) | |||
How do I link Text Boxes to Cells, not Cells to Text Boxes? | Excel Worksheet Functions | |||
In Excel, option to enter text in cells the same as text boxes | Excel Worksheet Functions |