+ Reply to Thread
Results 1 to 7 of 7

Macro to filter and copy

  1. #1
    Registered User
    Join Date
    10-14-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    98

    Macro to filter and copy

    Hello,

    I am trying to find a way to use a macro that will filter column O on the different name I have.
    Let's say that it will filter on "David" then it will copy from column A to P and paste in a new sheet.

    I have the following code:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to filter and copy

    Try this:

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to filter and copy

    What you have looks good too me? Note the changes:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-14-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    98

    Re: Macro to filter and copy

    How can I make it create a new sheet everytime I filter on a name ?

    Thank you for this awesome code

    Quote Originally Posted by JOHN H. DAVIS View Post
    What you have looks good too me? Note the changes:

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to filter and copy

    Maybe something like this.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to filter and copy

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-14-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    98

    Re: Macro to filter and copy

    It shows an error message for this line

    Please Login or Register  to view this content.
    Sub CopyRange()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Sheets("Data").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim response As String, ws As Worksheet
    Application.ScreenUpdating = False
    Set ws = ActiveSheet
    response = InputBox("please enter the name to filter.")
    Sheets.Add.Name = "New Sheet " & response
    ws.Activate
    Sheets("Data").Range("O1:O" & LastRow).AutoFilter Field:=1, Criteria1:=response
    Sheets("Data").Range("A1:P" & LastRow).SpecialCells(xlCellTypeVisible).Copy Sheets("New Sheet").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    If Sheets("Data").FilterMode Then Sheets("Data").ShowAllData
    Application.ScreenUpdating = True
    MsgBox "Done"
    End Sub
    [/QUOTE]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to filter and copy paste
    By arun.sj in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-24-2015, 04:26 AM
  2. [SOLVED] Macro to filter and copy to new excel
    By arun.sj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2015, 06:03 AM
  3. [SOLVED] Macro to filter and copy to new excel
    By arun.sj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-19-2015, 08:53 AM
  4. [SOLVED] Macro to filter, then copy
    By rayexcel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-30-2014, 04:53 AM
  5. [SOLVED] Macro for filter copy and paste
    By Chrisbrough88 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-13-2014, 08:13 AM
  6. Macro to Set Filter and Copy past
    By srikanthbenoni in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-28-2012, 08:02 AM
  7. Need macro to filter, create tab on filter and copy/paste
    By Jen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2006, 11:50 AM

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