+ Reply to Thread
Results 1 to 6 of 6

use DTPicker to select date and populate combobox

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    16

    use DTPicker to select date and populate combobox

    Hi All,

    I have a worksheet with dates in Column A and Names in Column B.

    Using a UserForm I want to be able to use the DTPicker to select a date and then using that value populate my combobox with possible names, in alphabetical order...

    Any ideas - i vaugly remember something about Array and a loop of sorts... not sure if this is the most efficient way.

    Any ideas for me to cunch out?

    Thanks,
    smartphreak

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: use DTPicker to select date and populate combobox

    Filter for the date, copy & paste visible rows to empty sheet. Use that data as the rowsource
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-29-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: use DTPicker to select date and populate combobox

    Hi Roy,

    Unfortunately no...

    I am running a UserForm.... it woudl not make sense to do that for every enquiry. There should be an easier way. ODBC perhaps?

    Just not sure of the coding.

  4. #4
    Registered User
    Join Date
    09-29-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: use DTPicker to select date and populate combobox

    Hi there,

    Trying your idea.... this is the code i have so far

    Private Sub DTPickerD_Change()

    Dim GUESTRANGE As Range
    Dim DateVal As Variant
    Dim nRow As Integer
    DateVal = Me.DTPickerD.Value

    Sheets("DATA").Select
    Selection.AutoFilter
    ActiveSheet.Range("A1:F100").AutoFilter Field:=1, Criteria1:= _
    "= & DateVal", Operator:=xlAnd

    Sheets("DATA").Range("A2:F100").Copy
    Sheets("Filter").Select
    Range("A1").Select
    ActiveCell.PasteSpecial xlPasteAll
    Range("b1", Range("b100").End(xlDown)).NAME = "GUESTRANGE"
    Range("b1", Range("f100").End(xlDown)).NAME = "myRANGE"

    Me.ComboBoxGuests.RowSource = "GUESTRANGE"
    End Sub
    This works when i substitute the "= & DateVal", in filter for an actual date ie "=11/11/2011" but i need the date to be dynamic so that when i select it from the DTPicker can populate the filter.

    Any thoughts?
    Thanks - smartphreak

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: use DTPicker to select date and populate combobox

    Please use Code Tags not Quote Tags

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: use DTPicker to select date and populate combobox

    I use that method regularly so I know it works. Your code will not work because you have
    "= & DateVal"
    This should be
    "="& DateVal
    You don't need to select

    I doubt if these work correctly
    Range("b1", Range("b100").End(xlDown)).NAME = "GUESTRANGE"
     Range("b1", Range("f100").End(xlDown)).NAME = "myRANGE"

+ 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.6.0 RC 1