PC Review


Reply
Thread Tools Rate Thread

combobox value <> range

 
 
=?Utf-8?B?U2hhd24=?=
Guest
Posts: n/a
 
      1st Jun 2007
I want a code that will make a combo box blank out if someone enters a value
other than a value in sheets("sheet1").range("a1:a10")


--
Thanks
Shawn
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      1st Jun 2007
Be careful with this code. You may have to change a value in the testrange
to get the combobox enabled after it has been disabled. also so I used
Combobox1.Text, you can also use Combobox1.value. Not usre if you are
comparing text or numbers.

Sub disablecombbox()

Set testrange = Sheets("sheet1").Range("a1:a10")
found = False
For Each cell In testrange

If cell = ComboBox1.Text Then
found = True
Exit For
End If
Next cell

If found = True Then
ComboBox1.enable = True
Else
ComboBox1.enable = False
End If

End Sub


"Shawn" wrote:

> I want a code that will make a combo box blank out if someone enters a value
> other than a value in sheets("sheet1").range("a1:a10")
>
>
> --
> Thanks
> Shawn

 
Reply With Quote
 
=?Utf-8?B?U2hhd24=?=
Guest
Posts: n/a
 
      1st Jun 2007
Numbers for some

text for others
--
Thanks
Shawn


"Joel" wrote:

> Be careful with this code. You may have to change a value in the testrange
> to get the combobox enabled after it has been disabled. also so I used
> Combobox1.Text, you can also use Combobox1.value. Not usre if you are
> comparing text or numbers.
>
> Sub disablecombbox()
>
> Set testrange = Sheets("sheet1").Range("a1:a10")
> found = False
> For Each cell In testrange
>
> If cell = ComboBox1.Text Then
> found = True
> Exit For
> End If
> Next cell
>
> If found = True Then
> ComboBox1.enable = True
> Else
> ComboBox1.enable = False
> End If
>
> End Sub
>
>
> "Shawn" wrote:
>
> > I want a code that will make a combo box blank out if someone enters a value
> > other than a value in sheets("sheet1").range("a1:a10")
> >
> >
> > --
> > Thanks
> > Shawn

 
Reply With Quote
 
=?Utf-8?B?U2hhd24=?=
Guest
Posts: n/a
 
      1st Jun 2007
Below is my code and it works good exept, when

If found = False Then
usfDemo.cmbxDOBMonth.Value = ""

I want it also re-select usfDemo.cmbxDOBMonth

I try usfDemo.cmbxDOBMonth.setfocus but that doesn't work

Private Sub cmbxDOBMonth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Set testrange = Sheets("Demo").Range("A2:A13")
found = False

For Each cell In testrange

If cell = usfDemo.cmbxDOBMonth.Value Then
found = True
Exit For
End If
Next cell

If found = False Then
usfDemo.cmbxDOBMonth.Value = ""
End If
End Sub
--
Thanks
Shawn


"Joel" wrote:

> Be careful with this code. You may have to change a value in the testrange
> to get the combobox enabled after it has been disabled. also so I used
> Combobox1.Text, you can also use Combobox1.value. Not usre if you are
> comparing text or numbers.
>
> Sub disablecombbox()
>
> Set testrange = Sheets("sheet1").Range("a1:a10")
> found = False
> For Each cell In testrange
>
> If cell = ComboBox1.Text Then
> found = True
> Exit For
> End If
> Next cell
>
> If found = True Then
> ComboBox1.enable = True
> Else
> ComboBox1.enable = False
> End If
>
> End Sub
>
>
> "Shawn" wrote:
>
> > I want a code that will make a combo box blank out if someone enters a value
> > other than a value in sheets("sheet1").range("a1:a10")
> >
> >
> > --
> > Thanks
> > Shawn

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Jun 2007
Why not change the style property of the combobox from fmStyleDropDownCombo
to fmStyleDropdownList. Then the user has to select from the list which will
of course be the list of acceptable values.

If you want to allow typing into the textbox region, then leave ti as
fmStyleDropDownCombo and and change the MatchRequired property to True.

from help on MatchRequired:
Specifies whether a value entered in the text portion of a ComboBox must
match an entry in the existing list portion of the control. The user can
enter non-matching values, but may not leave the control until a matching
value is entered.


--
Regards,
Tom Ogilvy

"Shawn" wrote:

> Below is my code and it works good exept, when
>
> If found = False Then
> usfDemo.cmbxDOBMonth.Value = ""
>
> I want it also re-select usfDemo.cmbxDOBMonth
>
> I try usfDemo.cmbxDOBMonth.setfocus but that doesn't work
>
> Private Sub cmbxDOBMonth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
> Set testrange = Sheets("Demo").Range("A2:A13")
> found = False
>
> For Each cell In testrange
>
> If cell = usfDemo.cmbxDOBMonth.Value Then
> found = True
> Exit For
> End If
> Next cell
>
> If found = False Then
> usfDemo.cmbxDOBMonth.Value = ""
> End If
> End Sub
> --
> Thanks
> Shawn
>
>
> "Joel" wrote:
>
> > Be careful with this code. You may have to change a value in the testrange
> > to get the combobox enabled after it has been disabled. also so I used
> > Combobox1.Text, you can also use Combobox1.value. Not usre if you are
> > comparing text or numbers.
> >
> > Sub disablecombbox()
> >
> > Set testrange = Sheets("sheet1").Range("a1:a10")
> > found = False
> > For Each cell In testrange
> >
> > If cell = ComboBox1.Text Then
> > found = True
> > Exit For
> > End If
> > Next cell
> >
> > If found = True Then
> > ComboBox1.enable = True
> > Else
> > ComboBox1.enable = False
> > End If
> >
> > End Sub
> >
> >
> > "Shawn" wrote:
> >
> > > I want a code that will make a combo box blank out if someone enters a value
> > > other than a value in sheets("sheet1").range("a1:a10")
> > >
> > >
> > > --
> > > Thanks
> > > Shawn

 
Reply With Quote
 
=?Utf-8?B?U2hhd24=?=
Guest
Posts: n/a
 
      1st Jun 2007
I have so much to learn. That works great.
--
Thanks
Shawn


"Tom Ogilvy" wrote:

> Why not change the style property of the combobox from fmStyleDropDownCombo
> to fmStyleDropdownList. Then the user has to select from the list which will
> of course be the list of acceptable values.
>
> If you want to allow typing into the textbox region, then leave ti as
> fmStyleDropDownCombo and and change the MatchRequired property to True.
>
> from help on MatchRequired:
> Specifies whether a value entered in the text portion of a ComboBox must
> match an entry in the existing list portion of the control. The user can
> enter non-matching values, but may not leave the control until a matching
> value is entered.
>
>
> --
> Regards,
> Tom Ogilvy
>
> "Shawn" wrote:
>
> > Below is my code and it works good exept, when
> >
> > If found = False Then
> > usfDemo.cmbxDOBMonth.Value = ""
> >
> > I want it also re-select usfDemo.cmbxDOBMonth
> >
> > I try usfDemo.cmbxDOBMonth.setfocus but that doesn't work
> >
> > Private Sub cmbxDOBMonth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
> > Set testrange = Sheets("Demo").Range("A2:A13")
> > found = False
> >
> > For Each cell In testrange
> >
> > If cell = usfDemo.cmbxDOBMonth.Value Then
> > found = True
> > Exit For
> > End If
> > Next cell
> >
> > If found = False Then
> > usfDemo.cmbxDOBMonth.Value = ""
> > End If
> > End Sub
> > --
> > Thanks
> > Shawn
> >
> >
> > "Joel" wrote:
> >
> > > Be careful with this code. You may have to change a value in the testrange
> > > to get the combobox enabled after it has been disabled. also so I used
> > > Combobox1.Text, you can also use Combobox1.value. Not usre if you are
> > > comparing text or numbers.
> > >
> > > Sub disablecombbox()
> > >
> > > Set testrange = Sheets("sheet1").Range("a1:a10")
> > > found = False
> > > For Each cell In testrange
> > >
> > > If cell = ComboBox1.Text Then
> > > found = True
> > > Exit For
> > > End If
> > > Next cell
> > >
> > > If found = True Then
> > > ComboBox1.enable = True
> > > Else
> > > ComboBox1.enable = False
> > > End If
> > >
> > > End Sub
> > >
> > >
> > > "Shawn" wrote:
> > >
> > > > I want a code that will make a combo box blank out if someone enters a value
> > > > other than a value in sheets("sheet1").range("a1:a10")
> > > >
> > > >
> > > > --
> > > > Thanks
> > > > Shawn

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
use ComboBox value to select range and then use selected range tocreate a chart Jerry Microsoft Excel Programming 3 22nd Jun 2011 02:15 PM
Range for combobox with IF KUMPFfrog Microsoft Excel Programming 4 28th Jan 2009 09:54 PM
RE: Combobox to range =?Utf-8?B?c2ViYXN0aWVubQ==?= Microsoft Excel Programming 0 26th Aug 2005 07:47 PM
Show one range in a combobox and write the 2nd range! Kevin Microsoft Excel Programming 1 17th Oct 2003 05:52 AM
ComboBox.Value To Range Hamilton R. Romano Microsoft Excel Programming 0 9th Sep 2003 05:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 AM.