Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default add up and calculate textboxes into a label

Hi,

I'm trying to add up and calculate 4 textboxes into a label.

This is how it should work:

First action:
TextBox1 + TextBox2 + TextBox3 + TextBox4 = "TOTAL"

Second action:
if "TOTAL" is equal or smaler than 4.99 == Label1 = 0
if "TOTAL" is between 5 and 9.99 == Label1 = 1
if "TOTAL" is between 10 and 14.99 == Label1 = 2
if "TOTAL" is between 15 and 19.99 == Label1 = 3
if "TOTAL" is between 20 and 24.99 == Label1 = 4
if "TOTAL" is equal or bigger than 25 == Label1 = 5

I would like to put the two actions into one vba-code.

Can you please help me out?

Regards,
Peter


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default add up and calculate textboxes into a label

Peter wrote:
First action:
TextBox1 + TextBox2 + TextBox3 + TextBox4 = "TOTAL"

Second action:
if "TOTAL" is equal or smaler than 4.99 == Label1 = 0
if "TOTAL" is between 5 and 9.99 == Label1 = 1
if "TOTAL" is between 10 and 14.99 == Label1 = 2
if "TOTAL" is between 15 and 19.99 == Label1 = 3
if "TOTAL" is between 20 and 24.99 == Label1 = 4
if "TOTAL" is equal or bigger than 25 == Label1 = 5


Dim dTotal As Double

With Me.Controls
dTotal = CDbl(.Item("TextBox1").Text) + CDbl(.Item("TextBox2").Text)
_
+ CDbl(.Item("TextBox3").Text) + CDbl(.Item("TextBox4").Text)
End With

If dTotal = 25 Then
Me.Label1.Caption = 5
ElseIf dTotal < 0 Then
Me.Label1.Caption = 1
Else
Me.Label1.Caption = Round((dTotal / 5) - 0.5)
End If

--
Dick Kusleika
MVP - Excel
Daily Dose of Excel
http://www.dicks-blog.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default add up and calculate textboxes into a label

You will have to use this code with some type of event procedure.

Dim total As Long

total = TextBox1.Value + TextBox2.Value + TextBox3.Value + TextBox4.Value

If total <= 4.99 Then Label1.Caption = 0
If total = 5 And total < 10 Then Label1.Caption = 1
If total = 10 And total < 15 Then Label1.Caption = 2
If total = 15 And total < 20 Then Label1.Caption = 3
If total = 20 And total < 25 Then Label1.Caption = 4
If total = 25 Then Label1.Caption = 5


"Peter" wrote:

Hi,

I'm trying to add up and calculate 4 textboxes into a label.

This is how it should work:

First action:
TextBox1 + TextBox2 + TextBox3 + TextBox4 = "TOTAL"

Second action:
if "TOTAL" is equal or smaler than 4.99 == Label1 = 0
if "TOTAL" is between 5 and 9.99 == Label1 = 1
if "TOTAL" is between 10 and 14.99 == Label1 = 2
if "TOTAL" is between 15 and 19.99 == Label1 = 3
if "TOTAL" is between 20 and 24.99 == Label1 = 4
if "TOTAL" is equal or bigger than 25 == Label1 = 5

I would like to put the two actions into one vba-code.

Can you please help me out?

Regards,
Peter



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default add up and calculate textboxes into a label

Thanks for the help Dick and David.
Both of them work nicely

Regards,
Peter


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
Changing the font for part of an axis label, not the whole label. amy45 Charts and Charting in Excel 2 April 5th 23 01:11 PM
How to rezize data label box in pie charts (label wraps to two lin rolliedogg Charts and Charting in Excel 1 October 18th 06 08:17 PM
COPY LABEL FORM FROM EXCEL TO A LABEL xrayAndi New Users to Excel 1 March 5th 06 02:21 PM
how to remove label formatting (eg label to number) sikkiekaka Excel Worksheet Functions 0 November 4th 04 11:35 PM
add text to label (label from forms toolbar) Rob Bovey Excel Programming 0 September 5th 03 09:46 PM


All times are GMT +1. The time now is 12:19 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"