+ Reply to Thread
Results 1 to 3 of 3

Sorting a table based on a value from a cell located in another sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    87

    Sorting a table based on a value from a cell located in another sheet

    Hello,
    I tried to record a macro to copy value of a cell in Sheet 1 and use it to filter a table in sheet 2 but the macro pulls in the absolute value that is in the cell for example in the code below


    Sub Macro3()
    '
    ' Macro3 Macro
    '
    
    '
        Range("A3").Select
        Selection.Copy
        Sheets("Sheet2").Select
        ActiveSheet.Range("$A$1:$C$7").AutoFilter Field:=1, Criteria1:="=2", _
            Operator:=xlAnd
    End Sub
    The sorting value is copied from A3 of Sheet 1 and then used to sort the table in Sheet 2 but as the code suggests the Criteria1:="=2" is taking the value at the time of recording the macro, how I can edit the macro to pull in whatever value is there in A3?


    Thanks,
    Aadesh.

  2. #2
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Sorting a table based on a value from a cell located in another sheet

    Sub Macro3()
    '
    ' Macro3 Macro
    '
    
    '
        Range("A3").Select
        Selection.Copy
        Sheets("Sheet2").Select
        ActiveSheet.Range("$A$1:$C$7").AutoFilter Field:=1, Criteria1:=Sheet1.Range("A3").Value, _
            Operator:=xlAnd
    End Sub

  3. #3
    Registered User
    Join Date
    08-13-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Sorting a table based on a value from a cell located in another sheet

    Works thanks!

+ 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