+ Reply to Thread
Results 1 to 15 of 15

Thread: select range from a value

  1. #1
    alvin Kuiper
    Guest

    select range from a value

    Hi
    If i in collumn a have dates This i can
    order by dates so far so god
    A date can bee the same several times
    Now I whant to have a Combobox With The dates in
    from cllumn A I can that, but if the date are there maybe 10 times i get the
    dates in my combobox 10 times
    I only what to see it One time ( In SQL i use Disinct)

    When i have this date and choose the date in the combobox i want to see the
    range the value are in
    Like if i choose "12-12-2006" and have this value in A20 to A25 then i want
    to see this "$a$20:$a:$25"

    Hoipe some one can help me with this.

    Regards

    Alvin



  2. #2
    Gary''s Student
    Guest

    RE: select range from a value

    Here is some code that you can adapt for your combobox.

    It looks down column A for a certain date and builds a range for the cells
    that contain that certain date. Once the range has been built, it is output
    in your desired format.



    Sub findrange()
    Dim s As String
    Dim ss As String
    Dim r As Range
    ss = "12/12/2006"
    For i = 1 To 100
    s = Cells(i, 1).Value
    If s = ss Then
    If r Is Nothing Then
    Set r = Cells(i, 1)
    Else
    Set r = Union(r, Cells(i, 1))
    End If
    End If
    Next
    MsgBox (r.Address)
    End Sub
    --
    Gary''s Student


    "alvin Kuiper" wrote:

    > Hi
    > If i in collumn a have dates This i can
    > order by dates so far so god
    > A date can bee the same several times
    > Now I whant to have a Combobox With The dates in
    > from cllumn A I can that, but if the date are there maybe 10 times i get the
    > dates in my combobox 10 times
    > I only what to see it One time ( In SQL i use Disinct)
    >
    > When i have this date and choose the date in the combobox i want to see the
    > range the value are in
    > Like if i choose "12-12-2006" and have this value in A20 to A25 then i want
    > to see this "$a$20:$a:$25"
    >
    > Hoipe some one can help me with this.
    >
    > Regards
    >
    > Alvin
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: select range from a value

    Alvin,

    here is some code that will work with a control toolbox combobox

    Private Sub ComboBox1_Click()
    MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    End Sub

    Private Sub ComboBox1_DropButtonClick()
    Dim i As Long
    Dim iStart As Long
    Dim iEnd As Long
    Dim dtePrev As Date
    Dim iArray As Long
    Dim ary

    dtePrev = 0: iArray = 1
    ReDim ary(1 To 2, 1 To 1)
    With Me
    .ComboBox1.Clear
    For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    If .Cells(i, "A").Value <> dtePrev Then
    If i <> 1 Then
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" &
    iEnd).Address
    iArray = iArray + 1
    End If
    iStart = i
    iEnd = i
    dtePrev = Me.Cells(i, "A").Value
    Else
    iEnd = i
    End If
    Next i
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    .ComboBox1.List = Application.Transpose(ary)
    End With

    End Sub

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > Hi
    > If i in collumn a have dates This i can
    > order by dates so far so god
    > A date can bee the same several times
    > Now I whant to have a Combobox With The dates in
    > from cllumn A I can that, but if the date are there maybe 10 times i get

    the
    > dates in my combobox 10 times
    > I only what to see it One time ( In SQL i use Disinct)
    >
    > When i have this date and choose the date in the combobox i want to see

    the
    > range the value are in
    > Like if i choose "12-12-2006" and have this value in A20 to A25 then i

    want
    > to see this "$a$20:$a:$25"
    >
    > Hoipe some one can help me with this.
    >
    > Regards
    >
    > Alvin
    >
    >




  4. #4
    alvin Kuiper
    Guest

    Re: select range from a value

    Hi bob
    I try this
    Private Sub combo_sedatoer_Click()
    MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)

    End Sub

    Private Sub combo_sedatoer_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim i As Long
    Dim iStart As Long
    Dim iEnd As Long
    Dim dtePrev As Date
    Dim iArray As Long
    Dim ary

    dtePrev = 0: iArray = 1
    ReDim ary(1 To 2, 1 To 1)
    With Me
    .combo_sedatoer.Clear
    For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    If .Cells(i, "A").Value <> dtePrev Then
    If i <> 1 Then
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    iArray = iArray + 1
    End If
    iStart = i
    iEnd = i
    dtePrev = Me.Cells(i, "A").Value
    Else
    iEnd = i
    End If
    Next i
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    .combo_sedatoer.List = Application.Transpose(ary)
    End With

    End Sub

    but when i use my dropdown i get a error in

    MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    don't know why
    Alvin



    "Bob Phillips" wrote:

    > Alvin,
    >
    > here is some code that will work with a control toolbox combobox
    >
    > Private Sub ComboBox1_Click()
    > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > End Sub
    >
    > Private Sub ComboBox1_DropButtonClick()
    > Dim i As Long
    > Dim iStart As Long
    > Dim iEnd As Long
    > Dim dtePrev As Date
    > Dim iArray As Long
    > Dim ary
    >
    > dtePrev = 0: iArray = 1
    > ReDim ary(1 To 2, 1 To 1)
    > With Me
    > .ComboBox1.Clear
    > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > If .Cells(i, "A").Value <> dtePrev Then
    > If i <> 1 Then
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" &
    > iEnd).Address
    > iArray = iArray + 1
    > End If
    > iStart = i
    > iEnd = i
    > dtePrev = Me.Cells(i, "A").Value
    > Else
    > iEnd = i
    > End If
    > Next i
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > .ComboBox1.List = Application.Transpose(ary)
    > End With
    >
    > End Sub
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > Hi
    > > If i in collumn a have dates This i can
    > > order by dates so far so god
    > > A date can bee the same several times
    > > Now I whant to have a Combobox With The dates in
    > > from cllumn A I can that, but if the date are there maybe 10 times i get

    > the
    > > dates in my combobox 10 times
    > > I only what to see it One time ( In SQL i use Disinct)
    > >
    > > When i have this date and choose the date in the combobox i want to see

    > the
    > > range the value are in
    > > Like if i choose "12-12-2006" and have this value in A20 to A25 then i

    > want
    > > to see this "$a$20:$a:$25"
    > >
    > > Hoipe some one can help me with this.
    > >
    > > Regards
    > >
    > > Alvin
    > >
    > >

    >
    >
    >


  5. #5
    alvin Kuiper
    Guest

    RE: select range from a value

    Hi garry
    Get an error in
    MsgBox (r.Address)

    Don't know why
    Alvin


    "Gary''s Student" wrote:

    > Here is some code that you can adapt for your combobox.
    >
    > It looks down column A for a certain date and builds a range for the cells
    > that contain that certain date. Once the range has been built, it is output
    > in your desired format.
    >
    >
    >
    > Sub findrange()
    > Dim s As String
    > Dim ss As String
    > Dim r As Range
    > ss = "12/12/2006"
    > For i = 1 To 100
    > s = Cells(i, 1).Value
    > If s = ss Then
    > If r Is Nothing Then
    > Set r = Cells(i, 1)
    > Else
    > Set r = Union(r, Cells(i, 1))
    > End If
    > End If
    > Next
    > MsgBox (r.Address)
    > End Sub
    > --
    > Gary''s Student
    >
    >
    > "alvin Kuiper" wrote:
    >
    > > Hi
    > > If i in collumn a have dates This i can
    > > order by dates so far so god
    > > A date can bee the same several times
    > > Now I whant to have a Combobox With The dates in
    > > from cllumn A I can that, but if the date are there maybe 10 times i get the
    > > dates in my combobox 10 times
    > > I only what to see it One time ( In SQL i use Disinct)
    > >
    > > When i have this date and choose the date in the combobox i want to see the
    > > range the value are in
    > > Like if i choose "12-12-2006" and have this value in A20 to A25 then i want
    > > to see this "$a$20:$a:$25"
    > >
    > > Hoipe some one can help me with this.
    > >
    > > Regards
    > >
    > > Alvin
    > >
    > >


  6. #6
    Bob Phillips
    Guest

    Re: select range from a value

    Alvin,

    I just renamed my combo to your name, but it still works fine for me.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > Hi bob
    > I try this
    > Private Sub combo_sedatoer_Click()
    > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    >
    > End Sub
    >
    > Private Sub combo_sedatoer_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    > Dim i As Long
    > Dim iStart As Long
    > Dim iEnd As Long
    > Dim dtePrev As Date
    > Dim iArray As Long
    > Dim ary
    >
    > dtePrev = 0: iArray = 1
    > ReDim ary(1 To 2, 1 To 1)
    > With Me
    > .combo_sedatoer.Clear
    > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > If .Cells(i, "A").Value <> dtePrev Then
    > If i <> 1 Then
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" &

    iEnd).Address
    > iArray = iArray + 1
    > End If
    > iStart = i
    > iEnd = i
    > dtePrev = Me.Cells(i, "A").Value
    > Else
    > iEnd = i
    > End If
    > Next i
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > .combo_sedatoer.List = Application.Transpose(ary)
    > End With
    >
    > End Sub
    >
    > but when i use my dropdown i get a error in
    >
    > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > don't know why
    > Alvin
    >
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Alvin,
    > >
    > > here is some code that will work with a control toolbox combobox
    > >
    > > Private Sub ComboBox1_Click()
    > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > End Sub
    > >
    > > Private Sub ComboBox1_DropButtonClick()
    > > Dim i As Long
    > > Dim iStart As Long
    > > Dim iEnd As Long
    > > Dim dtePrev As Date
    > > Dim iArray As Long
    > > Dim ary
    > >
    > > dtePrev = 0: iArray = 1
    > > ReDim ary(1 To 2, 1 To 1)
    > > With Me
    > > .ComboBox1.Clear
    > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > If .Cells(i, "A").Value <> dtePrev Then
    > > If i <> 1 Then
    > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > ary(1, iArray) = dtePrev
    > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > iEnd).Address
    > > iArray = iArray + 1
    > > End If
    > > iStart = i
    > > iEnd = i
    > > dtePrev = Me.Cells(i, "A").Value
    > > Else
    > > iEnd = i
    > > End If
    > > Next i
    > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > ary(1, iArray) = dtePrev
    > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > .ComboBox1.List = Application.Transpose(ary)
    > > End With
    > >
    > > End Sub
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from the email address if mailing direct)
    > >
    > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > Hi
    > > > If i in collumn a have dates This i can
    > > > order by dates so far so god
    > > > A date can bee the same several times
    > > > Now I whant to have a Combobox With The dates in
    > > > from cllumn A I can that, but if the date are there maybe 10 times i

    get
    > > the
    > > > dates in my combobox 10 times
    > > > I only what to see it One time ( In SQL i use Disinct)
    > > >
    > > > When i have this date and choose the date in the combobox i want to

    see
    > > the
    > > > range the value are in
    > > > Like if i choose "12-12-2006" and have this value in A20 to A25 then i

    > > want
    > > > to see this "$a$20:$a:$25"
    > > >
    > > > Hoipe some one can help me with this.
    > > >
    > > > Regards
    > > >
    > > > Alvin
    > > >
    > > >

    > >
    > >
    > >




  7. #7
    alvin Kuiper
    Guest

    Re: select range from a value

    Hi bob

    The combobox is it in a Userform or?

    Alvin


    "Bob Phillips" wrote:

    > Alvin,
    >
    > I just renamed my combo to your name, but it still works fine for me.
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > Hi bob
    > > I try this
    > > Private Sub combo_sedatoer_Click()
    > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > >
    > > End Sub
    > >
    > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    > > Dim i As Long
    > > Dim iStart As Long
    > > Dim iEnd As Long
    > > Dim dtePrev As Date
    > > Dim iArray As Long
    > > Dim ary
    > >
    > > dtePrev = 0: iArray = 1
    > > ReDim ary(1 To 2, 1 To 1)
    > > With Me
    > > .combo_sedatoer.Clear
    > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > If .Cells(i, "A").Value <> dtePrev Then
    > > If i <> 1 Then
    > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > ary(1, iArray) = dtePrev
    > > ary(2, iArray) = Range("A" & iStart & ":A" &

    > iEnd).Address
    > > iArray = iArray + 1
    > > End If
    > > iStart = i
    > > iEnd = i
    > > dtePrev = Me.Cells(i, "A").Value
    > > Else
    > > iEnd = i
    > > End If
    > > Next i
    > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > ary(1, iArray) = dtePrev
    > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > .combo_sedatoer.List = Application.Transpose(ary)
    > > End With
    > >
    > > End Sub
    > >
    > > but when i use my dropdown i get a error in
    > >
    > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > don't know why
    > > Alvin
    > >
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Alvin,
    > > >
    > > > here is some code that will work with a control toolbox combobox
    > > >
    > > > Private Sub ComboBox1_Click()
    > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > End Sub
    > > >
    > > > Private Sub ComboBox1_DropButtonClick()
    > > > Dim i As Long
    > > > Dim iStart As Long
    > > > Dim iEnd As Long
    > > > Dim dtePrev As Date
    > > > Dim iArray As Long
    > > > Dim ary
    > > >
    > > > dtePrev = 0: iArray = 1
    > > > ReDim ary(1 To 2, 1 To 1)
    > > > With Me
    > > > .ComboBox1.Clear
    > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > If i <> 1 Then
    > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > ary(1, iArray) = dtePrev
    > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > iEnd).Address
    > > > iArray = iArray + 1
    > > > End If
    > > > iStart = i
    > > > iEnd = i
    > > > dtePrev = Me.Cells(i, "A").Value
    > > > Else
    > > > iEnd = i
    > > > End If
    > > > Next i
    > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > ary(1, iArray) = dtePrev
    > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > .ComboBox1.List = Application.Transpose(ary)
    > > > End With
    > > >
    > > > End Sub
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > Hi
    > > > > If i in collumn a have dates This i can
    > > > > order by dates so far so god
    > > > > A date can bee the same several times
    > > > > Now I whant to have a Combobox With The dates in
    > > > > from cllumn A I can that, but if the date are there maybe 10 times i

    > get
    > > > the
    > > > > dates in my combobox 10 times
    > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > >
    > > > > When i have this date and choose the date in the combobox i want to

    > see
    > > > the
    > > > > range the value are in
    > > > > Like if i choose "12-12-2006" and have this value in A20 to A25 then i
    > > > want
    > > > > to see this "$a$20:$a:$25"
    > > > >
    > > > > Hoipe some one can help me with this.
    > > > >
    > > > > Regards
    > > > >
    > > > > Alvin
    > > > >
    > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  8. #8
    Bob Phillips
    Guest

    Re: select range from a value

    No what I gave you was for a worksheet control toolbox combo.

    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > Hi bob
    >
    > The combobox is it in a Userform or?
    >
    > Alvin
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Alvin,
    > >
    > > I just renamed my combo to your name, but it still works fine for me.
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from the email address if mailing direct)
    > >
    > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > Hi bob
    > > > I try this
    > > > Private Sub combo_sedatoer_Click()
    > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > >
    > > > End Sub
    > > >
    > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As

    MSForms.ReturnBoolean)
    > > > Dim i As Long
    > > > Dim iStart As Long
    > > > Dim iEnd As Long
    > > > Dim dtePrev As Date
    > > > Dim iArray As Long
    > > > Dim ary
    > > >
    > > > dtePrev = 0: iArray = 1
    > > > ReDim ary(1 To 2, 1 To 1)
    > > > With Me
    > > > .combo_sedatoer.Clear
    > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > If i <> 1 Then
    > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > ary(1, iArray) = dtePrev
    > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    > > iEnd).Address
    > > > iArray = iArray + 1
    > > > End If
    > > > iStart = i
    > > > iEnd = i
    > > > dtePrev = Me.Cells(i, "A").Value
    > > > Else
    > > > iEnd = i
    > > > End If
    > > > Next i
    > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > ary(1, iArray) = dtePrev
    > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > End With
    > > >
    > > > End Sub
    > > >
    > > > but when i use my dropdown i get a error in
    > > >
    > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > don't know why
    > > > Alvin
    > > >
    > > >
    > > >
    > > > "Bob Phillips" wrote:
    > > >
    > > > > Alvin,
    > > > >
    > > > > here is some code that will work with a control toolbox combobox
    > > > >
    > > > > Private Sub ComboBox1_Click()
    > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > End Sub
    > > > >
    > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > Dim i As Long
    > > > > Dim iStart As Long
    > > > > Dim iEnd As Long
    > > > > Dim dtePrev As Date
    > > > > Dim iArray As Long
    > > > > Dim ary
    > > > >
    > > > > dtePrev = 0: iArray = 1
    > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > With Me
    > > > > .ComboBox1.Clear
    > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > If i <> 1 Then
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > iEnd).Address
    > > > > iArray = iArray + 1
    > > > > End If
    > > > > iStart = i
    > > > > iEnd = i
    > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > Else
    > > > > iEnd = i
    > > > > End If
    > > > > Next i
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > End With
    > > > >
    > > > > End Sub
    > > > >
    > > > > --
    > > > >
    > > > > HTH
    > > > >
    > > > > Bob Phillips
    > > > >
    > > > > (remove nothere from the email address if mailing direct)
    > > > >
    > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    message
    > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > Hi
    > > > > > If i in collumn a have dates This i can
    > > > > > order by dates so far so god
    > > > > > A date can bee the same several times
    > > > > > Now I whant to have a Combobox With The dates in
    > > > > > from cllumn A I can that, but if the date are there maybe 10 times

    i
    > > get
    > > > > the
    > > > > > dates in my combobox 10 times
    > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > >
    > > > > > When i have this date and choose the date in the combobox i want

    to
    > > see
    > > > > the
    > > > > > range the value are in
    > > > > > Like if i choose "12-12-2006" and have this value in A20 to A25

    then i
    > > > > want
    > > > > > to see this "$a$20:$a:$25"
    > > > > >
    > > > > > Hoipe some one can help me with this.
    > > > > >
    > > > > > Regards
    > > > > >
    > > > > > Alvin
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




  9. #9
    alvin Kuiper
    Guest

    Re: select range from a value

    Ok
    Can i get it to work in a userform?

    Alvin

    "Bob Phillips" wrote:

    > No what I gave you was for a worksheet control toolbox combo.
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > Hi bob
    > >
    > > The combobox is it in a Userform or?
    > >
    > > Alvin
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Alvin,
    > > >
    > > > I just renamed my combo to your name, but it still works fine for me.
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > Hi bob
    > > > > I try this
    > > > > Private Sub combo_sedatoer_Click()
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > >
    > > > > End Sub
    > > > >
    > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As

    > MSForms.ReturnBoolean)
    > > > > Dim i As Long
    > > > > Dim iStart As Long
    > > > > Dim iEnd As Long
    > > > > Dim dtePrev As Date
    > > > > Dim iArray As Long
    > > > > Dim ary
    > > > >
    > > > > dtePrev = 0: iArray = 1
    > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > With Me
    > > > > .combo_sedatoer.Clear
    > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > If i <> 1 Then
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > iEnd).Address
    > > > > iArray = iArray + 1
    > > > > End If
    > > > > iStart = i
    > > > > iEnd = i
    > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > Else
    > > > > iEnd = i
    > > > > End If
    > > > > Next i
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > End With
    > > > >
    > > > > End Sub
    > > > >
    > > > > but when i use my dropdown i get a error in
    > > > >
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > don't know why
    > > > > Alvin
    > > > >
    > > > >
    > > > >
    > > > > "Bob Phillips" wrote:
    > > > >
    > > > > > Alvin,
    > > > > >
    > > > > > here is some code that will work with a control toolbox combobox
    > > > > >
    > > > > > Private Sub ComboBox1_Click()
    > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > Dim i As Long
    > > > > > Dim iStart As Long
    > > > > > Dim iEnd As Long
    > > > > > Dim dtePrev As Date
    > > > > > Dim iArray As Long
    > > > > > Dim ary
    > > > > >
    > > > > > dtePrev = 0: iArray = 1
    > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > With Me
    > > > > > .ComboBox1.Clear
    > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > If i <> 1 Then
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > iEnd).Address
    > > > > > iArray = iArray + 1
    > > > > > End If
    > > > > > iStart = i
    > > > > > iEnd = i
    > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > Else
    > > > > > iEnd = i
    > > > > > End If
    > > > > > Next i
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > End With
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > HTH
    > > > > >
    > > > > > Bob Phillips
    > > > > >
    > > > > > (remove nothere from the email address if mailing direct)
    > > > > >
    > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > message
    > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > Hi
    > > > > > > If i in collumn a have dates This i can
    > > > > > > order by dates so far so god
    > > > > > > A date can bee the same several times
    > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > from cllumn A I can that, but if the date are there maybe 10 times

    > i
    > > > get
    > > > > > the
    > > > > > > dates in my combobox 10 times
    > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > >
    > > > > > > When i have this date and choose the date in the combobox i want

    > to
    > > > see
    > > > > > the
    > > > > > > range the value are in
    > > > > > > Like if i choose "12-12-2006" and have this value in A20 to A25

    > then i
    > > > > > want
    > > > > > > to see this "$a$20:$a:$25"
    > > > > > >
    > > > > > > Hoipe some one can help me with this.
    > > > > > >
    > > > > > > Regards
    > > > > > >
    > > > > > > Alvin
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  10. #10
    alvin Kuiper
    Guest

    Re: select range from a value

    Hi bob
    I done it
    Thanks for your help

    Alvin


    "Bob Phillips" wrote:

    > No what I gave you was for a worksheet control toolbox combo.
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > Hi bob
    > >
    > > The combobox is it in a Userform or?
    > >
    > > Alvin
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Alvin,
    > > >
    > > > I just renamed my combo to your name, but it still works fine for me.
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > Hi bob
    > > > > I try this
    > > > > Private Sub combo_sedatoer_Click()
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > >
    > > > > End Sub
    > > > >
    > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As

    > MSForms.ReturnBoolean)
    > > > > Dim i As Long
    > > > > Dim iStart As Long
    > > > > Dim iEnd As Long
    > > > > Dim dtePrev As Date
    > > > > Dim iArray As Long
    > > > > Dim ary
    > > > >
    > > > > dtePrev = 0: iArray = 1
    > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > With Me
    > > > > .combo_sedatoer.Clear
    > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > If i <> 1 Then
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > iEnd).Address
    > > > > iArray = iArray + 1
    > > > > End If
    > > > > iStart = i
    > > > > iEnd = i
    > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > Else
    > > > > iEnd = i
    > > > > End If
    > > > > Next i
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > End With
    > > > >
    > > > > End Sub
    > > > >
    > > > > but when i use my dropdown i get a error in
    > > > >
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > don't know why
    > > > > Alvin
    > > > >
    > > > >
    > > > >
    > > > > "Bob Phillips" wrote:
    > > > >
    > > > > > Alvin,
    > > > > >
    > > > > > here is some code that will work with a control toolbox combobox
    > > > > >
    > > > > > Private Sub ComboBox1_Click()
    > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > Dim i As Long
    > > > > > Dim iStart As Long
    > > > > > Dim iEnd As Long
    > > > > > Dim dtePrev As Date
    > > > > > Dim iArray As Long
    > > > > > Dim ary
    > > > > >
    > > > > > dtePrev = 0: iArray = 1
    > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > With Me
    > > > > > .ComboBox1.Clear
    > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > If i <> 1 Then
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > iEnd).Address
    > > > > > iArray = iArray + 1
    > > > > > End If
    > > > > > iStart = i
    > > > > > iEnd = i
    > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > Else
    > > > > > iEnd = i
    > > > > > End If
    > > > > > Next i
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > End With
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > HTH
    > > > > >
    > > > > > Bob Phillips
    > > > > >
    > > > > > (remove nothere from the email address if mailing direct)
    > > > > >
    > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > message
    > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > Hi
    > > > > > > If i in collumn a have dates This i can
    > > > > > > order by dates so far so god
    > > > > > > A date can bee the same several times
    > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > from cllumn A I can that, but if the date are there maybe 10 times

    > i
    > > > get
    > > > > > the
    > > > > > > dates in my combobox 10 times
    > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > >
    > > > > > > When i have this date and choose the date in the combobox i want

    > to
    > > > see
    > > > > > the
    > > > > > > range the value are in
    > > > > > > Like if i choose "12-12-2006" and have this value in A20 to A25

    > then i
    > > > > > want
    > > > > > > to see this "$a$20:$a:$25"
    > > > > > >
    > > > > > > Hoipe some one can help me with this.
    > > > > > >
    > > > > > > Regards
    > > > > > >
    > > > > > > Alvin
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  11. #11
    alvin Kuiper
    Guest

    Re: select range from a value

    Just a little more help
    Its working
    but can i change it so it dosn't take the first row
    I will have this to a head line

    Alvin


    "Bob Phillips" wrote:

    > No what I gave you was for a worksheet control toolbox combo.
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > Hi bob
    > >
    > > The combobox is it in a Userform or?
    > >
    > > Alvin
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Alvin,
    > > >
    > > > I just renamed my combo to your name, but it still works fine for me.
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > Hi bob
    > > > > I try this
    > > > > Private Sub combo_sedatoer_Click()
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > >
    > > > > End Sub
    > > > >
    > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As

    > MSForms.ReturnBoolean)
    > > > > Dim i As Long
    > > > > Dim iStart As Long
    > > > > Dim iEnd As Long
    > > > > Dim dtePrev As Date
    > > > > Dim iArray As Long
    > > > > Dim ary
    > > > >
    > > > > dtePrev = 0: iArray = 1
    > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > With Me
    > > > > .combo_sedatoer.Clear
    > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > If i <> 1 Then
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > iEnd).Address
    > > > > iArray = iArray + 1
    > > > > End If
    > > > > iStart = i
    > > > > iEnd = i
    > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > Else
    > > > > iEnd = i
    > > > > End If
    > > > > Next i
    > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > ary(1, iArray) = dtePrev
    > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > End With
    > > > >
    > > > > End Sub
    > > > >
    > > > > but when i use my dropdown i get a error in
    > > > >
    > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > don't know why
    > > > > Alvin
    > > > >
    > > > >
    > > > >
    > > > > "Bob Phillips" wrote:
    > > > >
    > > > > > Alvin,
    > > > > >
    > > > > > here is some code that will work with a control toolbox combobox
    > > > > >
    > > > > > Private Sub ComboBox1_Click()
    > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > Dim i As Long
    > > > > > Dim iStart As Long
    > > > > > Dim iEnd As Long
    > > > > > Dim dtePrev As Date
    > > > > > Dim iArray As Long
    > > > > > Dim ary
    > > > > >
    > > > > > dtePrev = 0: iArray = 1
    > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > With Me
    > > > > > .ComboBox1.Clear
    > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > If i <> 1 Then
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > iEnd).Address
    > > > > > iArray = iArray + 1
    > > > > > End If
    > > > > > iStart = i
    > > > > > iEnd = i
    > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > Else
    > > > > > iEnd = i
    > > > > > End If
    > > > > > Next i
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > End With
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > --
    > > > > >
    > > > > > HTH
    > > > > >
    > > > > > Bob Phillips
    > > > > >
    > > > > > (remove nothere from the email address if mailing direct)
    > > > > >
    > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > message
    > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > Hi
    > > > > > > If i in collumn a have dates This i can
    > > > > > > order by dates so far so god
    > > > > > > A date can bee the same several times
    > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > from cllumn A I can that, but if the date are there maybe 10 times

    > i
    > > > get
    > > > > > the
    > > > > > > dates in my combobox 10 times
    > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > >
    > > > > > > When i have this date and choose the date in the combobox i want

    > to
    > > > see
    > > > > > the
    > > > > > > range the value are in
    > > > > > > Like if i choose "12-12-2006" and have this value in A20 to A25

    > then i
    > > > > > want
    > > > > > > to see this "$a$20:$a:$25"
    > > > > > >
    > > > > > > Hoipe some one can help me with this.
    > > > > > >
    > > > > > > Regards
    > > > > > >
    > > > > > > Alvin
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  12. #12
    Bob Phillips
    Guest

    Re: select range from a value

    Just start the loop from row 2 not 1


    For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row


    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    news:9A1147B1-329F-40A3-979D-A17FDB430394@microsoft.com...
    > Just a little more help
    > Its working
    > but can i change it so it dosn't take the first row
    > I will have this to a head line
    >
    > Alvin
    >
    >
    > "Bob Phillips" wrote:
    >
    > > No what I gave you was for a worksheet control toolbox combo.
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from the email address if mailing direct)
    > >
    > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > > Hi bob
    > > >
    > > > The combobox is it in a Userform or?
    > > >
    > > > Alvin
    > > >
    > > >
    > > > "Bob Phillips" wrote:
    > > >
    > > > > Alvin,
    > > > >
    > > > > I just renamed my combo to your name, but it still works fine for

    me.
    > > > >
    > > > > --
    > > > >
    > > > > HTH
    > > > >
    > > > > Bob Phillips
    > > > >
    > > > > (remove nothere from the email address if mailing direct)
    > > > >
    > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    message
    > > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > > Hi bob
    > > > > > I try this
    > > > > > Private Sub combo_sedatoer_Click()
    > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As

    > > MSForms.ReturnBoolean)
    > > > > > Dim i As Long
    > > > > > Dim iStart As Long
    > > > > > Dim iEnd As Long
    > > > > > Dim dtePrev As Date
    > > > > > Dim iArray As Long
    > > > > > Dim ary
    > > > > >
    > > > > > dtePrev = 0: iArray = 1
    > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > With Me
    > > > > > .combo_sedatoer.Clear
    > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > If i <> 1 Then
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > iEnd).Address
    > > > > > iArray = iArray + 1
    > > > > > End If
    > > > > > iStart = i
    > > > > > iEnd = i
    > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > Else
    > > > > > iEnd = i
    > > > > > End If
    > > > > > Next i
    > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > ary(1, iArray) = dtePrev
    > > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > > End With
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > but when i use my dropdown i get a error in
    > > > > >
    > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > > don't know why
    > > > > > Alvin
    > > > > >
    > > > > >
    > > > > >
    > > > > > "Bob Phillips" wrote:
    > > > > >
    > > > > > > Alvin,
    > > > > > >
    > > > > > > here is some code that will work with a control toolbox combobox
    > > > > > >
    > > > > > > Private Sub ComboBox1_Click()
    > > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > > End Sub
    > > > > > >
    > > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > > Dim i As Long
    > > > > > > Dim iStart As Long
    > > > > > > Dim iEnd As Long
    > > > > > > Dim dtePrev As Date
    > > > > > > Dim iArray As Long
    > > > > > > Dim ary
    > > > > > >
    > > > > > > dtePrev = 0: iArray = 1
    > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > With Me
    > > > > > > .ComboBox1.Clear
    > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > If i <> 1 Then
    > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > ary(1, iArray) = dtePrev
    > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > > iEnd).Address
    > > > > > > iArray = iArray + 1
    > > > > > > End If
    > > > > > > iStart = i
    > > > > > > iEnd = i
    > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > Else
    > > > > > > iEnd = i
    > > > > > > End If
    > > > > > > Next i
    > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > ary(1, iArray) = dtePrev
    > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    iEnd).Address
    > > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > > End With
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > > > --
    > > > > > >
    > > > > > > HTH
    > > > > > >
    > > > > > > Bob Phillips
    > > > > > >
    > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > >
    > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > > message
    > > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > > Hi
    > > > > > > > If i in collumn a have dates This i can
    > > > > > > > order by dates so far so god
    > > > > > > > A date can bee the same several times
    > > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > > from cllumn A I can that, but if the date are there maybe 10

    times
    > > i
    > > > > get
    > > > > > > the
    > > > > > > > dates in my combobox 10 times
    > > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > > >
    > > > > > > > When i have this date and choose the date in the combobox i

    want
    > > to
    > > > > see
    > > > > > > the
    > > > > > > > range the value are in
    > > > > > > > Like if i choose "12-12-2006" and have this value in A20 to

    A25
    > > then i
    > > > > > > want
    > > > > > > > to see this "$a$20:$a:$25"
    > > > > > > >
    > > > > > > > Hoipe some one can help me with this.
    > > > > > > >
    > > > > > > > Regards
    > > > > > > >
    > > > > > > > Alvin
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




  13. #13
    alvin Kuiper
    Guest

    Re: select range from a value

    Hi bob
    why i ask because i have try that
    and get error in
    ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address

    Alvin


    "Bob Phillips" wrote:

    > Just start the loop from row 2 not 1
    >
    >
    > For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
    >
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:9A1147B1-329F-40A3-979D-A17FDB430394@microsoft.com...
    > > Just a little more help
    > > Its working
    > > but can i change it so it dosn't take the first row
    > > I will have this to a head line
    > >
    > > Alvin
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > No what I gave you was for a worksheet control toolbox combo.
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > > > Hi bob
    > > > >
    > > > > The combobox is it in a Userform or?
    > > > >
    > > > > Alvin
    > > > >
    > > > >
    > > > > "Bob Phillips" wrote:
    > > > >
    > > > > > Alvin,
    > > > > >
    > > > > > I just renamed my combo to your name, but it still works fine for

    > me.
    > > > > >
    > > > > > --
    > > > > >
    > > > > > HTH
    > > > > >
    > > > > > Bob Phillips
    > > > > >
    > > > > > (remove nothere from the email address if mailing direct)
    > > > > >
    > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > message
    > > > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > > > Hi bob
    > > > > > > I try this
    > > > > > > Private Sub combo_sedatoer_Click()
    > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As
    > > > MSForms.ReturnBoolean)
    > > > > > > Dim i As Long
    > > > > > > Dim iStart As Long
    > > > > > > Dim iEnd As Long
    > > > > > > Dim dtePrev As Date
    > > > > > > Dim iArray As Long
    > > > > > > Dim ary
    > > > > > >
    > > > > > > dtePrev = 0: iArray = 1
    > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > With Me
    > > > > > > .combo_sedatoer.Clear
    > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > If i <> 1 Then
    > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > ary(1, iArray) = dtePrev
    > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > iEnd).Address
    > > > > > > iArray = iArray + 1
    > > > > > > End If
    > > > > > > iStart = i
    > > > > > > iEnd = i
    > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > Else
    > > > > > > iEnd = i
    > > > > > > End If
    > > > > > > Next i
    > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > ary(1, iArray) = dtePrev
    > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > > > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > > > End With
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > > > but when i use my dropdown i get a error in
    > > > > > >
    > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > > > don't know why
    > > > > > > Alvin
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > "Bob Phillips" wrote:
    > > > > > >
    > > > > > > > Alvin,
    > > > > > > >
    > > > > > > > here is some code that will work with a control toolbox combobox
    > > > > > > >
    > > > > > > > Private Sub ComboBox1_Click()
    > > > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > > > Dim i As Long
    > > > > > > > Dim iStart As Long
    > > > > > > > Dim iEnd As Long
    > > > > > > > Dim dtePrev As Date
    > > > > > > > Dim iArray As Long
    > > > > > > > Dim ary
    > > > > > > >
    > > > > > > > dtePrev = 0: iArray = 1
    > > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > > With Me
    > > > > > > > .ComboBox1.Clear
    > > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > > If i <> 1 Then
    > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > > > > > iEnd).Address
    > > > > > > > iArray = iArray + 1
    > > > > > > > End If
    > > > > > > > iStart = i
    > > > > > > > iEnd = i
    > > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > > Else
    > > > > > > > iEnd = i
    > > > > > > > End If
    > > > > > > > Next i
    > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    > iEnd).Address
    > > > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > > > End With
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > --
    > > > > > > >
    > > > > > > > HTH
    > > > > > > >
    > > > > > > > Bob Phillips
    > > > > > > >
    > > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > > >
    > > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in
    > > > message
    > > > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > > > Hi
    > > > > > > > > If i in collumn a have dates This i can
    > > > > > > > > order by dates so far so god
    > > > > > > > > A date can bee the same several times
    > > > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > > > from cllumn A I can that, but if the date are there maybe 10

    > times
    > > > i
    > > > > > get
    > > > > > > > the
    > > > > > > > > dates in my combobox 10 times
    > > > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > > > >
    > > > > > > > > When i have this date and choose the date in the combobox i

    > want
    > > > to
    > > > > > see
    > > > > > > > the
    > > > > > > > > range the value are in
    > > > > > > > > Like if i choose "12-12-2006" and have this value in A20 to

    > A25
    > > > then i
    > > > > > > > want
    > > > > > > > > to see this "$a$20:$a:$25"
    > > > > > > > >
    > > > > > > > > Hoipe some one can help me with this.
    > > > > > > > >
    > > > > > > > > Regards
    > > > > > > > >
    > > > > > > > > Alvin
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


  14. #14
    Bob Phillips
    Guest

    Re: select range from a value

    It also needs to test for starting at row 2 later

    Private Sub combo_sedatoer_DropButtonClick()
    Dim i As Long
    Dim iStart As Long
    Dim iEnd As Long
    Dim dtePrev As Date
    Dim iArray As Long
    Dim ary

    dtePrev = 0: iArray = 1
    ReDim ary(1 To 2, 1 To 1)
    With Me
    .combo_sedatoer.Clear
    For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
    If .Cells(i, "A").Value <> dtePrev Then
    If i <> 2 Then
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" & _
    iEnd).Address
    iArray = iArray + 1
    End If
    iStart = i
    iEnd = i
    dtePrev = Me.Cells(i, "A").Value
    Else
    iEnd = i
    End If
    Next i
    ReDim Preserve ary(1 To 2, 1 To iArray)
    ary(1, iArray) = dtePrev
    ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    .combo_sedatoer.List = Application.Transpose(ary)
    End With

    End Sub


    --

    HTH

    Bob Phillips

    (remove nothere from the email address if mailing direct)

    "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    news:95A634D1-5985-475D-9F7D-066D88BF4DEF@microsoft.com...
    > Hi bob
    > why i ask because i have try that
    > and get error in
    > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    >
    > Alvin
    >
    >
    > "Bob Phillips" wrote:
    >
    > > Just start the loop from row 2 not 1
    > >
    > >
    > > For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
    > >
    > >
    > > --
    > >
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from the email address if mailing direct)
    > >
    > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > news:9A1147B1-329F-40A3-979D-A17FDB430394@microsoft.com...
    > > > Just a little more help
    > > > Its working
    > > > but can i change it so it dosn't take the first row
    > > > I will have this to a head line
    > > >
    > > > Alvin
    > > >
    > > >
    > > > "Bob Phillips" wrote:
    > > >
    > > > > No what I gave you was for a worksheet control toolbox combo.
    > > > >
    > > > > --
    > > > >
    > > > > HTH
    > > > >
    > > > > Bob Phillips
    > > > >
    > > > > (remove nothere from the email address if mailing direct)
    > > > >
    > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    message
    > > > > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > > > > Hi bob
    > > > > >
    > > > > > The combobox is it in a Userform or?
    > > > > >
    > > > > > Alvin
    > > > > >
    > > > > >
    > > > > > "Bob Phillips" wrote:
    > > > > >
    > > > > > > Alvin,
    > > > > > >
    > > > > > > I just renamed my combo to your name, but it still works fine

    for
    > > me.
    > > > > > >
    > > > > > > --
    > > > > > >
    > > > > > > HTH
    > > > > > >
    > > > > > > Bob Phillips
    > > > > > >
    > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > >
    > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > > message
    > > > > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > > > > Hi bob
    > > > > > > > I try this
    > > > > > > > Private Sub combo_sedatoer_Click()
    > > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex,

    1)
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As
    > > > > MSForms.ReturnBoolean)
    > > > > > > > Dim i As Long
    > > > > > > > Dim iStart As Long
    > > > > > > > Dim iEnd As Long
    > > > > > > > Dim dtePrev As Date
    > > > > > > > Dim iArray As Long
    > > > > > > > Dim ary
    > > > > > > >
    > > > > > > > dtePrev = 0: iArray = 1
    > > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > > With Me
    > > > > > > > .combo_sedatoer.Clear
    > > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > > If i <> 1 Then
    > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A"

    &
    > > > > > > iEnd).Address
    > > > > > > > iArray = iArray + 1
    > > > > > > > End If
    > > > > > > > iStart = i
    > > > > > > > iEnd = i
    > > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > > Else
    > > > > > > > iEnd = i
    > > > > > > > End If
    > > > > > > > Next i
    > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    iEnd).Address
    > > > > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > > > > End With
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > but when i use my dropdown i get a error in
    > > > > > > >
    > > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > > > > don't know why
    > > > > > > > Alvin
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > > "Bob Phillips" wrote:
    > > > > > > >
    > > > > > > > > Alvin,
    > > > > > > > >
    > > > > > > > > here is some code that will work with a control toolbox

    combobox
    > > > > > > > >
    > > > > > > > > Private Sub ComboBox1_Click()
    > > > > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > > > > Dim i As Long
    > > > > > > > > Dim iStart As Long
    > > > > > > > > Dim iEnd As Long
    > > > > > > > > Dim dtePrev As Date
    > > > > > > > > Dim iArray As Long
    > > > > > > > > Dim ary
    > > > > > > > >
    > > > > > > > > dtePrev = 0: iArray = 1
    > > > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > > > With Me
    > > > > > > > > .ComboBox1.Clear
    > > > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > > > If i <> 1 Then
    > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > ary(2, iArray) = Range("A" & iStart &

    ":A" &
    > > > > > > > > iEnd).Address
    > > > > > > > > iArray = iArray + 1
    > > > > > > > > End If
    > > > > > > > > iStart = i
    > > > > > > > > iEnd = i
    > > > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > > > Else
    > > > > > > > > iEnd = i
    > > > > > > > > End If
    > > > > > > > > Next i
    > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    > > iEnd).Address
    > > > > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > > > > End With
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > --
    > > > > > > > >
    > > > > > > > > HTH
    > > > > > > > >
    > > > > > > > > Bob Phillips
    > > > > > > > >
    > > > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > > > >
    > > > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote

    in
    > > > > message
    > > > > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > > > > Hi
    > > > > > > > > > If i in collumn a have dates This i can
    > > > > > > > > > order by dates so far so god
    > > > > > > > > > A date can bee the same several times
    > > > > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > > > > from cllumn A I can that, but if the date are there maybe

    10
    > > times
    > > > > i
    > > > > > > get
    > > > > > > > > the
    > > > > > > > > > dates in my combobox 10 times
    > > > > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > > > > >
    > > > > > > > > > When i have this date and choose the date in the combobox

    i
    > > want
    > > > > to
    > > > > > > see
    > > > > > > > > the
    > > > > > > > > > range the value are in
    > > > > > > > > > Like if i choose "12-12-2006" and have this value in A20

    to
    > > A25
    > > > > then i
    > > > > > > > > want
    > > > > > > > > > to see this "$a$20:$a:$25"
    > > > > > > > > >
    > > > > > > > > > Hoipe some one can help me with this.
    > > > > > > > > >
    > > > > > > > > > Regards
    > > > > > > > > >
    > > > > > > > > > Alvin
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >




  15. #15
    alvin Kuiper
    Guest

    Re: select range from a value

    Many many thanks bob
    now its working with all i want
    Thanks again

    Best regards

    Alvin


    "Bob Phillips" wrote:

    > It also needs to test for starting at row 2 later
    >
    > Private Sub combo_sedatoer_DropButtonClick()
    > Dim i As Long
    > Dim iStart As Long
    > Dim iEnd As Long
    > Dim dtePrev As Date
    > Dim iArray As Long
    > Dim ary
    >
    > dtePrev = 0: iArray = 1
    > ReDim ary(1 To 2, 1 To 1)
    > With Me
    > .combo_sedatoer.Clear
    > For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
    > If .Cells(i, "A").Value <> dtePrev Then
    > If i <> 2 Then
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" & _
    > iEnd).Address
    > iArray = iArray + 1
    > End If
    > iStart = i
    > iEnd = i
    > dtePrev = Me.Cells(i, "A").Value
    > Else
    > iEnd = i
    > End If
    > Next i
    > ReDim Preserve ary(1 To 2, 1 To iArray)
    > ary(1, iArray) = dtePrev
    > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > .combo_sedatoer.List = Application.Transpose(ary)
    > End With
    >
    > End Sub
    >
    >
    > --
    >
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from the email address if mailing direct)
    >
    > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > news:95A634D1-5985-475D-9F7D-066D88BF4DEF@microsoft.com...
    > > Hi bob
    > > why i ask because i have try that
    > > and get error in
    > > ary(2, iArray) = Range("A" & iStart & ":A" & iEnd).Address
    > >
    > > Alvin
    > >
    > >
    > > "Bob Phillips" wrote:
    > >
    > > > Just start the loop from row 2 not 1
    > > >
    > > >
    > > > For i = 2 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > >
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in message
    > > > news:9A1147B1-329F-40A3-979D-A17FDB430394@microsoft.com...
    > > > > Just a little more help
    > > > > Its working
    > > > > but can i change it so it dosn't take the first row
    > > > > I will have this to a head line
    > > > >
    > > > > Alvin
    > > > >
    > > > >
    > > > > "Bob Phillips" wrote:
    > > > >
    > > > > > No what I gave you was for a worksheet control toolbox combo.
    > > > > >
    > > > > > --
    > > > > >
    > > > > > HTH
    > > > > >
    > > > > > Bob Phillips
    > > > > >
    > > > > > (remove nothere from the email address if mailing direct)
    > > > > >
    > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in

    > message
    > > > > > news:B22E2F36-0539-4533-924F-939AB79614D4@microsoft.com...
    > > > > > > Hi bob
    > > > > > >
    > > > > > > The combobox is it in a Userform or?
    > > > > > >
    > > > > > > Alvin
    > > > > > >
    > > > > > >
    > > > > > > "Bob Phillips" wrote:
    > > > > > >
    > > > > > > > Alvin,
    > > > > > > >
    > > > > > > > I just renamed my combo to your name, but it still works fine

    > for
    > > > me.
    > > > > > > >
    > > > > > > > --
    > > > > > > >
    > > > > > > > HTH
    > > > > > > >
    > > > > > > > Bob Phillips
    > > > > > > >
    > > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > > >
    > > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote in
    > > > message
    > > > > > > > news:B932F528-39FA-4771-A50D-6465F8DA0F67@microsoft.com...
    > > > > > > > > Hi bob
    > > > > > > > > I try this
    > > > > > > > > Private Sub combo_sedatoer_Click()
    > > > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex,

    > 1)
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Private Sub combo_sedatoer_DblClick(ByVal Cancel As
    > > > > > MSForms.ReturnBoolean)
    > > > > > > > > Dim i As Long
    > > > > > > > > Dim iStart As Long
    > > > > > > > > Dim iEnd As Long
    > > > > > > > > Dim dtePrev As Date
    > > > > > > > > Dim iArray As Long
    > > > > > > > > Dim ary
    > > > > > > > >
    > > > > > > > > dtePrev = 0: iArray = 1
    > > > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > > > With Me
    > > > > > > > > .combo_sedatoer.Clear
    > > > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > > > If i <> 1 Then
    > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A"

    > &
    > > > > > > > iEnd).Address
    > > > > > > > > iArray = iArray + 1
    > > > > > > > > End If
    > > > > > > > > iStart = i
    > > > > > > > > iEnd = i
    > > > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > > > Else
    > > > > > > > > iEnd = i
    > > > > > > > > End If
    > > > > > > > > Next i
    > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &

    > iEnd).Address
    > > > > > > > > .combo_sedatoer.List = Application.Transpose(ary)
    > > > > > > > > End With
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > but when i use my dropdown i get a error in
    > > > > > > > >
    > > > > > > > > MsgBox Me.combo_sedatoer.List(Me.combo_sedatoer.ListIndex, 1)
    > > > > > > > > don't know why
    > > > > > > > > Alvin
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "Bob Phillips" wrote:
    > > > > > > > >
    > > > > > > > > > Alvin,
    > > > > > > > > >
    > > > > > > > > > here is some code that will work with a control toolbox

    > combobox
    > > > > > > > > >
    > > > > > > > > > Private Sub ComboBox1_Click()
    > > > > > > > > > MsgBox Me.ComboBox1.List(Me.ComboBox1.ListIndex, 1)
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > Private Sub ComboBox1_DropButtonClick()
    > > > > > > > > > Dim i As Long
    > > > > > > > > > Dim iStart As Long
    > > > > > > > > > Dim iEnd As Long
    > > > > > > > > > Dim dtePrev As Date
    > > > > > > > > > Dim iArray As Long
    > > > > > > > > > Dim ary
    > > > > > > > > >
    > > > > > > > > > dtePrev = 0: iArray = 1
    > > > > > > > > > ReDim ary(1 To 2, 1 To 1)
    > > > > > > > > > With Me
    > > > > > > > > > .ComboBox1.Clear
    > > > > > > > > > For i = 1 To .Cells(Rows.Count, "A").End(xlUp).Row
    > > > > > > > > > If .Cells(i, "A").Value <> dtePrev Then
    > > > > > > > > > If i <> 1 Then
    > > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > > ary(2, iArray) = Range("A" & iStart &

    > ":A" &
    > > > > > > > > > iEnd).Address
    > > > > > > > > > iArray = iArray + 1
    > > > > > > > > > End If
    > > > > > > > > > iStart = i
    > > > > > > > > > iEnd = i
    > > > > > > > > > dtePrev = Me.Cells(i, "A").Value
    > > > > > > > > > Else
    > > > > > > > > > iEnd = i
    > > > > > > > > > End If
    > > > > > > > > > Next i
    > > > > > > > > > ReDim Preserve ary(1 To 2, 1 To iArray)
    > > > > > > > > > ary(1, iArray) = dtePrev
    > > > > > > > > > ary(2, iArray) = Range("A" & iStart & ":A" &
    > > > iEnd).Address
    > > > > > > > > > .ComboBox1.List = Application.Transpose(ary)
    > > > > > > > > > End With
    > > > > > > > > >
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > --
    > > > > > > > > >
    > > > > > > > > > HTH
    > > > > > > > > >
    > > > > > > > > > Bob Phillips
    > > > > > > > > >
    > > > > > > > > > (remove nothere from the email address if mailing direct)
    > > > > > > > > >
    > > > > > > > > > "alvin Kuiper" <alvinKuiper@discussions.microsoft.com> wrote

    > in
    > > > > > message
    > > > > > > > > > news:98222798-273A-4F43-9D9C-74D947BAD2DC@microsoft.com...
    > > > > > > > > > > Hi
    > > > > > > > > > > If i in collumn a have dates This i can
    > > > > > > > > > > order by dates so far so god
    > > > > > > > > > > A date can bee the same several times
    > > > > > > > > > > Now I whant to have a Combobox With The dates in
    > > > > > > > > > > from cllumn A I can that, but if the date are there maybe

    > 10
    > > > times
    > > > > > i
    > > > > > > > get
    > > > > > > > > > the
    > > > > > > > > > > dates in my combobox 10 times
    > > > > > > > > > > I only what to see it One time ( In SQL i use Disinct)
    > > > > > > > > > >
    > > > > > > > > > > When i have this date and choose the date in the combobox

    > i
    > > > want
    > > > > > to
    > > > > > > > see
    > > > > > > > > > the
    > > > > > > > > > > range the value are in
    > > > > > > > > > > Like if i choose "12-12-2006" and have this value in A20

    > to
    > > > A25
    > > > > > then i
    > > > > > > > > > want
    > > > > > > > > > > to see this "$a$20:$a:$25"
    > > > > > > > > > >
    > > > > > > > > > > Hoipe some one can help me with this.
    > > > > > > > > > >
    > > > > > > > > > > Regards
    > > > > > > > > > >
    > > > > > > > > > > Alvin
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0