How Do I Get A ComboBox To Add Entry To It's List If Not In List
Hey Tom,
This looks good, I do have some questions, what does the resize do
and what is the "ABC" for?
The rowsource for CB1 (ComboBox1) is a named range called "lVender"
which has this code:
=OFFSET(List!$B$2,0,0,COUNTA(List!$B:$B),1)
Most of the ComboBoxes are text (all but 2) so the Match(cdbl(sVal)
will come in handy for those 2.
I am trying to understand the code so that I can modify it
intelligently.
Like why is the row source emptied and then given a different name
( rng.resize(rng.rows.count+1,1).Name = "ABC"
combobox1.rowSource = "ABC")
Thanks for the assistance.
-Minitman
On Mon, 3 Oct 2005 14:34:36 -0400, "Tom Ogilvy"
wrote:
Use the exit event, then code like this I would think
Dim rng as Range, sVal as String, res as Variant
set rng = Range(combobox1.Rowsource)
sVal = combobox1.Value
res = Application.Match(sVal,rng,0)
if iserror(res) then
rng.offset(rng.rows.count,0).Resize(1,1).Value = _
combobox1.value
combobox1.rowSource = ""
rng.resize(rng.rows.count+1,1).Name = "ABC"
combobox1.rowSource = "ABC"
combobox1.Value = sVale
end if
If the values in the range are numbers, you might have to do
Match(cdbl(sVal), . . .
--
Regards,
Tom Ogilvy
"Minitman" wrote in message
.. .
Hey Tom,
Thanks for the reply.
The ComboBox is located on a UserForm called UserForm1. The list is
located on a sheet called "List". Each ComboBox uses a named range
which is a column on "List" as the row source.
I was trying to keep the post short, I guess I succeeded too well.
<G
-Minitman
On Mon, 3 Oct 2005 12:27:01 -0400, "Tom Ogilvy"
wrote:
Where is the combobox located. What type of combobox - control toolbox
or
Forms
The location may well answer the second, but not if it is a worksheet.
--
Regards,
Tom Ogilvy
"Minitman" wrote in message
.. .
Greetings,
If the entry that I just made to the ComboBox is not in the list, I
have a ControlButton that I click on that will copy the entry to the
list and then resort the list. What I want to do is have the ComboBox
do this on exiting without having to click on the ControlButton.
Any one have any ideas as to how this can be done?
TIA
-Minitman
|