Results 1 to 9 of 9

Use Combo Box To Define Which Column To Autofilter

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664

    Use Combo Box To Define Which Column To Autofilter

    Hi all,

    Same project as yesterday...different problem!

    I have a list of dates relating to various stages in a project. What I'd like to do is when a button is pressed on the spreadsheet a user form pops up - this is done, no problem. On the userform I have two sets of data input - the first is a combo box which displays the various stages of the project (i.e. column headers). The second is a text box where the user enters a date - dd/mm/yyyy.

    On the worksheet I have an autofilter across the header columns. What I'm trying to do is when the 'Search' button is pressed, get the code to run the autofilter on a column depending on which entry is chosen from the drop down on the combo box. e.g: if 'Feasibility Upload' is chosen the autofilter on column B is run, if 'RD Sign Off' is chosen the autofilter on column H is run, etc.

    The date part isn't such a biggie. I'm going to use something along the lines of:

    Private Sub projSearch_Click()
    
     Dim sData As String
     
     sData =  dateData
      
     Selection.AutoFilter Field:=1, Criteria1:=sData
     
     Unload Me
       
     End Sub
    However, the line:

    Selection.AutoFilter Field:=1, Criteria1:=sData
    ...needs to be dependent on the combo box. One last thing, if the date isn't in the column I'd like a message to come up saying something along the lines of "Date not found".

    Hope that makes sense. Any help greatly appreciated.

    TIA,

    SamuelT
    Last edited by SamuelT; 10-18-2007 at 09:51 AM.

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