+ Reply to Thread
Results 1 to 2 of 2

Combo Box - Please Help!

  1. #1

    Combo Box - Please Help!

    I have posted this twice before and cannot get a response! Please help
    me out. Thanks, Chris


    Hi-


    I have a combo box that is populated by a list in the same sheet. The
    combo box contains 4 different categories of data that when clicked
    will autofilter the sheet named "excel" based on which category was
    selected in the combo box.


    Here is the code have:


    Private Sub ComboBox1_Change()


    Sheets("excel").Select
    Selection.AutoFilter Field:=8, Criteria1:="=0"
    Selection.AutoFilter Field:=10, Criteria1:="=1"


    What I want to add to this code is an If Statement that will change the

    sort based on what is selected in the combo. So say the combo has 4
    entries: 1,2,3,4. Let's say the user selects 3 this time and then
    comes back and selects 4. Here is what I would like to do:


    Private Sub ComboBox1_Change()


    If (Value selected in Combo box) Is 3 Then
    Sheets("excel").Select
    Selection.AutoFilter Field:=8, Criteria1:="=0"
    Selection.AutoFilter Field:=10, Criteria1:="=1"


    End If


    If (Value selected in Combo box) Is 4 Then
    Sheets("excel").Select
    Selection.AutoFilter Field:=8, Criteria1:="=0"
    Selection.AutoFilter Field:=10, Criteria1:="=1"


    End If


    I may be better served with a Select Case....but either way I do not
    know how to code. Can you offer your suggestion on a if vs. a select
    and how to code each one?


    HUGE thanks in advance for your time and help!


    -Chris


  2. #2
    Bob Phillips
    Guest

    Re: Combo Box - Please Help!

    What is different between the 3 case and the 4 case?

    --
    HTH

    Bob Phillips

    <[email protected]> wrote in message
    news:[email protected]...
    > I have posted this twice before and cannot get a response! Please help
    > me out. Thanks, Chris
    >
    >
    > Hi-
    >
    >
    > I have a combo box that is populated by a list in the same sheet. The
    > combo box contains 4 different categories of data that when clicked
    > will autofilter the sheet named "excel" based on which category was
    > selected in the combo box.
    >
    >
    > Here is the code have:
    >
    >
    > Private Sub ComboBox1_Change()
    >
    >
    > Sheets("excel").Select
    > Selection.AutoFilter Field:=8, Criteria1:="=0"
    > Selection.AutoFilter Field:=10, Criteria1:="=1"
    >
    >
    > What I want to add to this code is an If Statement that will change the
    >
    > sort based on what is selected in the combo. So say the combo has 4
    > entries: 1,2,3,4. Let's say the user selects 3 this time and then
    > comes back and selects 4. Here is what I would like to do:
    >
    >
    > Private Sub ComboBox1_Change()
    >
    >
    > If (Value selected in Combo box) Is 3 Then
    > Sheets("excel").Select
    > Selection.AutoFilter Field:=8, Criteria1:="=0"
    > Selection.AutoFilter Field:=10, Criteria1:="=1"
    >
    >
    > End If
    >
    >
    > If (Value selected in Combo box) Is 4 Then
    > Sheets("excel").Select
    > Selection.AutoFilter Field:=8, Criteria1:="=0"
    > Selection.AutoFilter Field:=10, Criteria1:="=1"
    >
    >
    > End If
    >
    >
    > I may be better served with a Select Case....but either way I do not
    > know how to code. Can you offer your suggestion on a if vs. a select
    > and how to code each one?
    >
    >
    > HUGE thanks in advance for your time and help!
    >
    >
    > -Chris
    >




+ 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