Results 1 to 5 of 5

Thread: _Change() to filter data in a worksheet from userform

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    2

    _Change() to filter data in a worksheet from userform

    I have userform that I am using to take a bunch of data. I also want to function as a way to query past data. I have it set up to pull a graph from the worksheet and display as an image in the form. It updates every time the user changes a listbox with a _change().

    What I need to learn is how to filter the WS from the listbox selection and then regraph the data right before I pull the graph the image.

    Thanks for any suggestions!

    ThugDragon

    p.s. using excel 2002

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: _Change() to filter data in a worksheet from userform

    try recording a macro of filtering the data, to generate some sample code
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: _Change() to filter data in a worksheet from userform

    Welcome to VBForums

    Thread moved to 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    2

    Re: _Change() to filter data in a worksheet from userform

    Thansk for the tip for doing a macro!
    Here is the code I recieve from recording the macro (however I'm doing this at home in excel 2007) where as at work it must work on 2002.

    Column A was a number, column B was a date (is that why it uses 'Operator:=' and 'Criteria2:=' ?)

    Sub Macro3()
    '
    ' Macro3 Macro
    ' Select from both autofilters column a&b
    '

    '
    ActiveSheet.Range("$A$1:$B$12").AutoFilter Field:=1, Criteria1:="3"
    ActiveSheet.Range("$A$1:$B$12").AutoFilter Field:=2, Operator:= _
    xlFilterValues, Criteria2:=Array(2, "2/2/1990")
    End Sub


    So... if I put a 'listboxentry1.value' in place of "3" that line should work inserted into a _change()?


    Thanks,
    ThugDragon

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: _Change() to filter data in a worksheet from userform

    So... if I put a 'listboxentry1.value' in place of "3" that line should work inserted into a _change()?
    i think that should be right, try it and see
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width