+ Reply to Thread
Results 1 to 3 of 3

Select Data Based on User Input

Hybrid View

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Select Data Based on User Input

    Hello,

    I attached an excel document to help me explain what I want to do. In the excel document I have a list of boxes with their length, width, height, etc on Sheet1. On Sheet2 I have an area (the grey section) where the user can input their maximum and minimum requirements of length, width, and height for the boxes. After inputing the information, I want excel to automatically select the boxes that meet this criteria or (user input) and copy these boxes with all their informaiton onto Sheet2 (Underneath the User Input section).

    Any help would be greatly appreciated.
    Please let me know if anything needs to be clarified.

    Thanks!
    Attached Files Attached Files
    Last edited by scurveydog; 10-03-2010 at 12:37 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Select Data Based on User Input

    This macro will do it:
    Option Explicit
    
    Sub AutoFilterCopy()
    Dim LR As Long
    
    If Application.WorksheetFunction.Count(Range("B4:C6")) < 6 Then
        MsgBox "All gray cells must have values"
        Exit Sub
    End If
    
    Application.ScreenUpdating = False
    Range("A11").CurrentRegion.Clear
    
    With Sheets("Sheet1")
        .Range("A1").AutoFilter
        .Range("A1").AutoFilter Field:=2, Criteria1:=">=" & Range("C5"), Operator:=xlAnd, _
            Criteria2:="<=" & Range("B5")
        .Range("A1").AutoFilter Field:=3, Criteria1:=">=" & Range("C4"), Operator:=xlAnd, _
            Criteria2:="<=" & Range("B4")
        .Range("A1").AutoFilter Field:=4, Criteria1:=">=" & Range("C6"), Operator:=xlAnd, _
            Criteria2:="<=" & Range("B6")
        LR = .Range("A" & .Rows.Count).End(xlUp).Row
        If LR > 1 Then
            .Range("A1").CurrentRegion.Copy Range("A11")
        Else
            Range("A11") = "None Found"
        End If
        .AutoFilterMode = False
    End With
    
    Application.ScreenUpdating = True
    End Sub

    I've placed a button on your sheet for you, just click the button and it will update your list.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-28-2010
    Location
    Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Select Data Based on User Input

    Wow! Thanks a lot.

+ 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