+ Reply to Thread
Results 1 to 18 of 18

Changing Auto Filter Based on User Inputted Cell

  1. #1
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31

    Changing Auto Filter Based on User Inputted Cell

    I have a Workbook that has 2 worksheets, one called CALL QUERY and one called CALL LOG. On the CALL QUERY sheet, cell D9 is a user inputted cell with the cell validation set to list. The user uses the dripdown list to pick an office identifier (3-Letter Code).

    On the CALL LOG sheet, I have info about individual calls. Column E has the 3-letter office identifier for each call.

    I am trying to find a way to automatically auto filter the list on the CALL LOG sheet with the user input in cell D9 on the CALL QUERY sheet.

    I was given the following code: (N2 is a cell on the CALL LOG sheet that equals the user inputted cell D9 on the CALL QUERY sheet)

    Please Login or Register  to view this content.
    I opened the VBA window using ALT-F11 and I double-clicked on the sheet that I wanted the auto filtering to apply to, and I entered this code. Once I closed the VBA window, I did multiple cahnges to the user inputted field and nothing happened on the auto filter sheet.

    Is there something I am doing wrong? I was told this code works on the worksheet's SelectionChange event so whenever the user changes the input, it will autofilter the data. I am new to the SelectionChange event. Thanks for any help. - John

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Looks like the code you have is looking at cell N2 not D9 to filter Col E in Sheet1.

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Since D9 is on a different sheet, I made N2 on the sheet that I want to autofilter = D9 on the user input sheet.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Sorry didn't stop that

    What sheet is the event code in.

    The code is looking for Sheet1 but you mention Call log and call query sheets

    Prehaps that is the problem


    VBA Noob

  5. #5
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    The event code is on the Call Log Sheet. I see in the VBA window it lists it as Sheet3 (Call Log).

    I have tried changing the code where it says "Sheet1" to "Sheet3" and "Sheet3 (Call Log)" and "Call Log" with no effect.

    I am trying to have the user input an office identifier value on one sheet, and have the data on the other sheet be auto-filtered based on the user entered office identifier without having to click on the auto-filter drop down arrow to select the value.

    If the code is written in the worksheet's SelectionChange Event, should it automatically have the data auto-filtered when I select that sheet?

  6. #6
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Looking at the VBA window, I expanded where is says VBAProject (CST Call Log.xls) and then expanded the Microsoft Excel Objects folder under that and double clicked on Sheet3 (Call Log). That opened a new window and I entered the above listed code. Am I doing this coding in the correct place? I see there is also a modules folder under this workbook.

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    Please Login or Register  to view this content.
    VBA Noob

  8. #8
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    I really appriciate you spending so much time on this with me. I entered the code exactly as you wrote, with no luck. This leads me to believe I am either putting the code in the wrond place or there is some other step that I don't know about.

    Do I need to have the auto-filter turned on on the worksheet where the auto-filter arrows are present? Are there any other settings that need to be on for this coding to work?

    Thanks again for all you time.

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try this example

    VBA Noob
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Yours worked better than mine. I saw that you had different code than mine. Yours didn't autofilter the data until I clicked on N2. Once I clicked on N2 (I didn't change it, just selected it) the autofilter worked. Is there any way to make the autofilter execute when the user selects the Call Log sheet?

  11. #11
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Does it matter that my column header is in row 5 and my data starts in row 6?

  12. #12
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    It will work when they active the call log sheet

    Please Login or Register  to view this content.
    VBA Noob

  13. #13
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Noob,

    I don't know that I have ever had this much trouble with Excel. I changed my code to be exactly like your new code, and I get a runtime error. The debugger has a problem with:
    Please Login or Register  to view this content.
    Yours worked great. It just seams like I have a setting wrong that it doesn't run my code correctly. Never thought this was such a tough issue.

  14. #14
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    I cut & Paste your new code into the sample worksheet you provided and it work EXACTLY like I wanted it to. Not sure what is wrong with mine.

  15. #15
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Make sure your sheet is called Call Log with no spaces

    VBA Noob

  16. #16
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    urgh....My code is exactly like yours and my sheet names are exactly like yours and it still doesn't work. I get a Runtime error 1004 - Application-defined or object-defined error.

    With your new code, your sample sheet works just right.

  17. #17
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Not sure what the problem is.
    Can you upload the workbook

    VBA Noob

  18. #18
    Registered User
    Join Date
    01-06-2006
    Location
    Omaha, NE
    Posts
    31
    Noob,

    Thanks for all your help. I got it a bit closer. I cut and past from you message to my VBA window and it now kinda works. It does auto filter now when I select the coll log sheet, but it is not finding a match for my user input criteria. I think this has to do with the fact that the fileds being auto-filtered are auto populated from another sheet via a formula. So it looks like the sutofilter sees the cell value as the formula code and not the value of the formula. I think I am just going to have the users utilize the autofilter drop down arrows. I was hoping to avoid that, but I'm not sure what else to do. Thanks again for helping with this issue as well as helping with posting correctly. John

+ 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