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

Hi all

I have 4 comboboxes on my userform and they are called c1 c2 c3 and c4 I
want to have excel check up to make sure the same value is not used twice.
I have tries this myself and have not suceeded because of when it is left
blank it activates the code i have written to warn of duplicates.

Can some one help me with this

Thanks

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Combobox Query

This may help you get started. The code goes in the Userform module

Option Explicit

Private Sub c1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If c1 < "" Then
If c1 = c2.Value _
Or c1 = c3.Value _
Or c1 = c4.Value Then
MsgBox "That value is already used."
Else
MsgBox "Okay"
''Do something here - your code
End If
End If
End Sub

"Greg" wrote:

Hi all

I have 4 comboboxes on my userform and they are called c1 c2 c3 and c4 I
want to have excel check up to make sure the same value is not used twice.
I have tries this myself and have not suceeded because of when it is left
blank it activates the code i have written to warn of duplicates.

Can some one help me with this

Thanks

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Combobox Query


I assume that your code does not give special treatment to blank cells.
When left blank, your code detects two empty strings and finds that
they are the same. Hence it executes the code for duplicates.

If you want to disallow blank inputs, simply check for that first and
exit from the code if any blank inputs are found.

If you want to check for duplicates while ignoring blank cells you can
use the following condition when comparing two values:

if(c1.value<"" and c2.value<"" and c1.value=c2.value) then
execute code for duplicates
endif


--
C01d
------------------------------------------------------------------------
C01d's Profile: http://www.excelforum.com/member.php...o&userid=34422
View this thread: http://www.excelforum.com/showthread...hreadid=544149

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Combobox Query

Thanks for that

Greg
"C01d" wrote in message
...

I assume that your code does not give special treatment to blank cells.
When left blank, your code detects two empty strings and finds that
they are the same. Hence it executes the code for duplicates.

If you want to disallow blank inputs, simply check for that first and
exit from the code if any blank inputs are found.

If you want to check for duplicates while ignoring blank cells you can
use the following condition when comparing two values:

if(c1.value<"" and c2.value<"" and c1.value=c2.value) then
execute code for duplicates
endif


--
C01d
------------------------------------------------------------------------
C01d's Profile:
http://www.excelforum.com/member.php...o&userid=34422
View this thread: http://www.excelforum.com/showthread...hreadid=544149



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
Combobox query? Greg B[_8_] Excel Programming 2 March 14th 06 12:35 AM
ComboBox Filled by Query DBAL[_6_] Excel Programming 3 May 12th 05 02:22 AM
Combobox query Nigel Excel Discussion (Misc queries) 1 April 29th 05 11:56 AM
Tricky ComboBox / Filter query [email protected] Excel Discussion (Misc queries) 0 December 11th 04 10:37 PM
Combobox Query Maxime Maugeais Excel Programming 1 November 17th 04 11:36 AM


All times are GMT +1. The time now is 09:27 AM.

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"