Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Two Counters Limit Total

Hi

I have two incremental counters on a form where users can enter two
scores (home and away). I want to limit the total of the two scores to
100. I'm thinking of two options and would appreciate any help with
how to do it.

Let's assume the total of the two scores is currently 100 and the user
clicks on the up arrow to increase the home score by 1, the options
a

1. The home score doesn't change and an error message appears asking
the user to reduce the away score first.
[On this one I don't know how to stop the home score increasing. The
score continues to increase within its own parameters.]

or

2. The home counter increases as the user clicks the up arrow but the
away score decreases to maintain a maximum total of 100.

Win2K XL2K

Many thanks
Nikki
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Two Counters Limit Total

Assuming the values go to textboxes, this stps the counter going above 100

Private Sub SpinButton1_SpinUp()
With TextBox1
.Value = .Value + 1
If .Value 100 Then
.Value = 100
End If
End With
End Sub

This shows how to increment one, decrement the other

Private Sub SpinButton1_SpinUp()
With TextBox1
.Text = .Text + 1
If .Text 100 Then
If TextBox2.Text 0 Then
TextBox2.Text = TextBox2.Text - 1
Else
.Text = .Text - 1
End If
End If
End With
End Sub

--

HTH

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

"Nikki" wrote in message
om...
Hi

I have two incremental counters on a form where users can enter two
scores (home and away). I want to limit the total of the two scores to
100. I'm thinking of two options and would appreciate any help with
how to do it.

Let's assume the total of the two scores is currently 100 and the user
clicks on the up arrow to increase the home score by 1, the options
a

1. The home score doesn't change and an error message appears asking
the user to reduce the away score first.
[On this one I don't know how to stop the home score increasing. The
score continues to increase within its own parameters.]

or

2. The home counter increases as the user clicks the up arrow but the
away score decreases to maintain a maximum total of 100.

Win2K XL2K

Many thanks
Nikki



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
How do you limit the total allowed for a group of cells? abby Excel Discussion (Misc queries) 1 May 5th 10 03:25 AM
What does Excel do when you go over the limit for total data point Carl Charts and Charting in Excel 3 April 8th 09 03:16 PM
Create an if-then formula in Excel to limit column total? Nancy M Excel Discussion (Misc queries) 2 February 13th 05 10:47 PM
Counters Paul Excel Worksheet Functions 2 February 11th 05 01:52 PM
counters tag Excel Programming 0 September 14th 03 12:48 AM


All times are GMT +1. The time now is 11:46 PM.

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"