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


Excel 2003
Visual Basic 6.3

I have a form with 24 text boxes. The names of the text boxes all
start with “txt”, e.g. txtCHOL, txtALB, etc. The values that are
entered into the text boxes can range from 1 to 24. Is there an easy
way (VB code) to check that each box has a different number, that is,
mutually exclusive.

Thanks


--
scantor145
------------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=528559

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Mutually exclusive values

Dim tb As Control
Dim collNums As Collection
Dim cTBs As Long

Set collNums = New Collection
For Each tb In Me.Controls
If TypeName(tb) = "TextBox" Then
cTBs = cTBs + 1
On Error Resume Next
collNums.Add tb.Text, tb.Text
On Error GoTo 0
End If
Next tb
If collNums.Count < cTBs Then
MsgBox "All values must be unique"
End If


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"scantor145" wrote
in message ...

Excel 2003
Visual Basic 6.3

I have a form with 24 text boxes. The names of the text boxes all
start with "txt", e.g. txtCHOL, txtALB, etc. The values that are
entered into the text boxes can range from 1 to 24. Is there an easy
way (VB code) to check that each box has a different number, that is,
mutually exclusive.

Thanks


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:

http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=528559



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
Is there a way to make 6 columns mutually exclusive? Sandie D Excel Worksheet Functions 1 November 20th 06 10:09 PM
2 IF Statements not mutually exclusive Bev Excel Discussion (Misc queries) 2 August 24th 06 05:23 AM
Making checkboxes mutually exclusive instructorjml Excel Discussion (Misc queries) 3 April 6th 06 06:45 AM
Help: Multiple filters with mutually exclusive items six50joe Excel Discussion (Misc queries) 5 September 28th 05 02:41 PM
Req: How to create multiple mutually exclusive filters six50joe Excel Worksheet Functions 2 September 26th 05 11:08 PM


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