+ Reply to Thread
Results 1 to 8 of 8

Copy filtered rows in one worksheet and paste to other worksheet

  1. #1
    Registered User
    Join Date
    02-03-2013
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2007-2010
    Posts
    7

    Copy filtered rows in one worksheet and paste to other worksheet

    Friends,
    Totally new to the Excel VBA or Macros. Was just doing first Macro where I want to filter rows in one worksheet and copy them to other worksheet but macro copies all the row to other work sheet. Please see below and guide. Thanks for your help.
    Please Login or Register  to view this content.
    Last edited by vlady; 02-03-2013 at 10:55 PM. Reason: code tags

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    Hi, tsiddiq23,

    welcome to ExcelForum. You maybe need to reduce the raneg to only the visible rows. While being in Excel, choose the range via Mouse, hit F5, press the left button (I only have a local german version, should read either Contents or options), choose visible cells from there, the press CTRL+Copy.

    Using VBA you can use SpecialCells(xlCellTypeVisible) for reducing the range:
    Please Login or Register  to view this content.
    If there aren´t any formulas in the data you could use the destination directly after the Copy like
    Please Login or Register  to view this content.
    Could you please put code tags around the macro you´re showing? Thanks in advance.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    You could try to replace these lines in your macro:

    Please Login or Register  to view this content.
    with this:

    Please Login or Register  to view this content.
    If you wish to include the headings from the autofilter settings use

    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    Alf

    Ps When you post code you should wrap it (forum rule)

  4. #4
    Registered User
    Join Date
    02-03-2013
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2007-2010
    Posts
    7

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    Hi Ciao,
    Thank you for your reply. I do not know how to use the modification you wrote above. See below is complete code that came out when I recorded the macro. I am filtering two columns (separately) in Active Sheet and past (one by one) the filtered rows in "Filter BL Date" worksheet next to Active sheet. I want the rows I get after filtering to be pasted to in "Filter BL Date" worksheet. Sorry, I am totally new to the macros so do not know much about VBA yet. Thanks again for your help.

    Please Login or Register  to view this content.
    Last edited by tsiddiq23; 02-03-2013 at 07:33 PM.

  5. #5
    Registered User
    Join Date
    02-03-2013
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2007-2010
    Posts
    7

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    Hi Alf,
    Thanks for your reply. When I replaced the code with yours, it gave me Run_time error"1004". Method 'Range of object'_Global' failed. I think I am not understanding/using it properly. Will try again.
    Regards,

    Tahir

  6. #6
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    Put the date in Cell R1.
    Please Login or Register  to view this content.
    Kind regards, Harry.

  7. #7
    Registered User
    Join Date
    02-03-2013
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 2007-2010
    Posts
    7

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    Hi Harry,
    Thanks for your reply. My Active sheet where my data resides (I call it 'Main' sheet) has row 1 as Fields and other rows contain data. 9th and 10th columns are date columns where I filter dates as required. You suggested to put date in cell R1. but R1 is one of the Fields heading. So, how it will work? Thanks again.

    Regards,
    Tahir

  8. #8
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Copy filtered rows in one worksheet and paste to other worksheet

    There are a lot cells in Excel, choose one.

+ 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