+ Reply to Thread
Results 1 to 3 of 3

Modifying sort data macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Modifying sort data macro

    I have the following macro that sorts column G and H ascending so that the rows with "Yes" in column G and H come to the top. Next I would like to copy all rows with a Yes in them into B50 and all rows without a yes in column G or H into B100. Can someone help me finish this macro?

    
    
    
    
    
    Sub Filter()
      
       Application.ScreenUpdating = False
       
       Dim Wks As Worksheet
        Set Wks = ActiveSheet
        Wks.Activate
        
        Filter2
        
        Application.ScreenUpdating = True
    End Sub
    
    
    
    
    
    Private Sub Filter2()
    'First line
    Dim i As Long, LR As Long
    
    i = 446
    
    Range("B3:BY4").AutoFilter
    Selection.Sort Key1:=Range("G4"), Order1:=xlAscending, Header:= _
    xlGuess, Orientation:=xlTopToBottom
    Selection.Sort Key1:=Range("H4"), Order1:=xlAscending, Header:= _
    xlGuess, Orientation:=xlTopToBottom
    
    
    
    
    ActiveSheet.AutoFilterMode = False
    Application.CutCopyMode = False
        
    
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    01-05-2010
    Location
    New York
    MS-Off Ver
    Excel 2016
    Posts
    747

    Re: Modifying sort data macro

    Can anyone help me with this?

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Modifying sort data macro

    Quote Originally Posted by rhudgins View Post
    I have the following macro that sorts column G and H ascending so that the rows with "Yes" in column G and H come to the top. Next I would like to copy all rows with a Yes in them into B50 and all rows without a yes in column G or H into B100. Can someone help me finish this macro?
    If there are 2 rows with a Yes in them, how do you want 2 rows copied into B50?
    If there are 2 rows without a Yes in them, how do you want 2 rows copied into B100?

    Are you saying that you want all rows with 1 Yes in them moved down to row 50?
    Are you saying that you want all rows with no Yeses in them moved down to row 100?
    If so, suppose there are more than 50 rows with 2 Yeses in them, do you want them overwritten?

    Try explaining again.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

+ 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