Re: Combo Box

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I really do not understand what you are trying to do here, you test an
object for David, and if true, set it to David!

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"magix" <magix@xxxxxxxx> wrote in message
news:43a193d3$1_2@xxxxxxxxxxxxxxxxx
> Hi Bob,
>
> If I use your dictionary code, then in Change event, how should I do ? is
it
> like this ? But I think this is not so appropriate.
>
> let say in my combo box, i have list
> David
> Johnson
> Michael
>
> Private Sub ComboBox1_Change()
> Select Case ComboBox1.Text
> Case "David"
> Me.ComboBox1.Value = "David"
> Case "Johnson"
> Me.ComboBox1.Value = "Johnson"
> Case "Michael"
> Me.ComboBox1.Value = "Michael"
> Case Else
> End Select
> End Sub
>
> If not, what is the appropriate one, with respect to your dictionary
object
> ?
>
> BestRegards,
> Magix
>
> "Bob Phillips" <bob.phillips@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:O5Pq4mMAGHA.2704@xxxxxxxxxxxxxxxxxxxxxxx
> > 1. Why would you want multiple values on the change. What I gave you
> showed
> > you how to get the selected value. probably in the click event. If you
are
> > trying to load the combobox. you need
> >
> > Me.Combobox1.AddItem "David"
> >
> > etc., but not in the change event, in the userform ac tivate event.
> >
> > 2. Again in userform activate when you are getting all the values.
> >
> > --
> > HTH
> >
> > Bob Phillips
> >
> > (remove nothere from email address if mailing direct)
> >
> > "magix" <magix@xxxxxxxx> wrote in message
> news:43a03be4_2@xxxxxxxxxxxxxxxxx
> > > Hi Bob,
> > >
> > > 1. Do you mean I put like this ?
> > > Private Sub ComboBox1_Change()
> > > Me.Combobox1.Value = "David"
> > > Me.Combobox1.Value = "Rebecca"
> > > Me.Combobox1.Value = "Kenix"
> > > Me.Combobox1.Value = "Isaac"
> > > End Sub
> > >
> > > 2. Where should I put this code that you written ? in " Private Sub
> > > ComboBox1_Change( )" ?
> > > Dim oDic As Object
> > > ...
> > > ...
> > > ...
> > > Set oDic = Nothing
> > >
> > > Regards.
> > >
> > >
> > > "Bob Phillips" <bob.phillips@xxxxxxxxxxxxxxxxxxxx> wrote in message
> > > news:OedlNOAAGHA.3064@xxxxxxxxxxxxxxxxxxxxxxx
> > > > 1. Me.Combobox1.Value
> > > >
> > > > 2. Use a dictionary onject
> > > >
> > > > Dim oDic As Object
> > > > Dim i As Long
> > > > Dim aItems
> > > > Set oDic = CreateObject("Scripting.Dictionary")
> > > > On Error Resume Next
> > > > For i = 1 To Range("A1").End(xlDown).Row
> > > > oDic.Add Cells(i, "A").Value, Cells(i, "A")
> > > > End With
> > > > On Error GoTo 0
> > > >
> > > > 'trabsefr dictionary to an array
> > > > aItems = oDic.Items
> > > > With Me.combobox1
> > > > .Clear
> > > > For i = 0 To oDic.Count - 1
> > > > .AddItem aItems(i)
> > > > Next
> > > > End With
> > > > Set oDic = Nothing
> > > >
> > > > 3. In the OK button click event
> > > >
> > > > Activesheet.Range("A1").Value = me.Combobox1.Value
> > > >
> > > > --
> > > > HTH
> > > >
> > > > Bob Phillips
> > > >
> > > > (remove nothere from email address if mailing direct)
> > > >
> > > > "magix" <magix@xxxxxxxx> wrote in message
> > > > news:439eefb1$1_1@xxxxxxxxxxxxxxxxx
> > > > > Hi,
> > > > >
> > > > > In my userform, i have
> > > > >
> > > > > Firstname: <DropdownList>
> > > > >
> > > > > Question:
> > > > > 1. If I want the value of DropDownList to be read from code, how
can
> I
> > > do
> > > > it
> > > > > via code by hardcoding the entries in combobox_change() function ?
> > > > > Private Sub ComboBox1_Change()
> > > > > ....
> > > > > End Sub
> > > > >
> > > > > 2. If I want the value of DropDownList to be read from Column
A1:A10
> > > (note
> > > > > there are redundant value, how to avoid ?)
> > > > > Example:
> > > > > A1: Johnson
> > > > > A2: Stephen
> > > > > A3: Michael
> > > > > A4: Daryl
> > > > > A5: Michael
> > > > > A6: Johnson
> > > > > A7: Rebecca
> > > > > A8: Johnson
> > > > > A9: Sally
> > > > > A10: Sally
> > > > >
> > > > > So the drop down list will actually read from A1: A10 and have
> > only
> > > > > Johnson
> > > > > Stephen
> > > > > Michael
> > > > > Daryl
> > > > > Rebecca
> > > > > Sally
> > > > >
> > > > >
> > > > > 3. After I click OK in the userform, how can I pass the selected
> value
> > > to
> > > > my
> > > > > module code ?
> > > > >
> > > > > Please advise. Thanks
> > > > >
> > > > > Regards,
> > > > > Magix
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


.



Relevant Pages

  • Re: How to prevent dialog box
    ... David ... "Bob Phillips" wrote: ... > (remove nothere from the email address if mailing direct) ... >>> HTH ...
    (microsoft.public.excel.programming)
  • Re: Help with formula, IF, AND, OR, etc.
    ... "Bob Phillips" wrote: ... > HTH ... >> Thank you David. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Combo Box
    ... > object for David, and if true, set it to David! ... >> If I use your dictionary code, then in Change event, how should I do? ... >> Private Sub ComboBox1_Change ... >>> Bob Phillips ...
    (microsoft.public.excel)
  • Re: Combo Box
    ... >> object for David, and if true, set it to David! ... >> HTH ... >> Bob Phillips ... >> (remove nothere from email address if mailing direct) ...
    (microsoft.public.excel)
  • Re: Combo Box
    ... > object for David, and if true, set it to David! ... >> If I use your dictionary code, then in Change event, how should I do? ... >> Private Sub ComboBox1_Change ... >>> Bob Phillips ...
    (microsoft.public.excel)