+ Reply to Thread
Results 1 to 3 of 3

Filter based on a condition and copy paste to another sheet

  1. #1
    Registered User
    Join Date
    11-03-2021
    Location
    India
    MS-Off Ver
    2010
    Posts
    6

    Filter based on a condition and copy paste to another sheet

    Hi All, I have an excel data which is a tedious task, so i broke it down as steps to automate but Iam not good at custom VBA code. if the below conditions are met then need to copy the entire filtered table to a new sheet and next copy should pasted down to the first copied table, its a continues copy paste in the same sheet.

    **Please see the image in attachment to see the data.

    Basically the hack for calculations of number of copies are here : if Col6 is "Yes" then (Col2 x 3 sets) + (col3 x 4 sets) + (col4 x 1 sets) = total 8 sets of copies of filtered table. if Col6 is "No" then (Col2 x 2 sets) + (col3 x 4 sets) + (col4 x 1 sets) = total 7 sets of copies of filtered table.

    Something is blank then count comes down example: if col2 is blank then col3 x 4 sets + Col4 x 1 = 5 sets of filtered table of all 7 columns should copy to another sheet.

    Elaboration of the above summary is below:

    a) Defined Conditions for non -blank cells: (do not copy hidden cells)
    1. Filter non blank cells of all Col2,Col3,Col4
    2. after filtering non blank cells of all three need check Col6 is Yes or No
    3. if col6 is "Yes" then we need to copy all those Non blank rows (not hidden rows) which are Yes to another sheet and the number of times it should copy the all filtered rows or table total of 8 sets.(meaning copy 8 times) and should write Col7 as "First" for first copy and "Second" for second copy etc.
    4. if col6 is "No" then should copy entire filtered rows 7 times or 7 sets.


    b) Defined Conditions for blank and non -blank cells: (do not copy hidden cells):
    1. if col2 is blank but col3 and col4 is non-blank then entire filtered rows copy 5 times to new sheet mention "First" copy, "second copy in Col7 as it is to identify which copy(no need to check for Col6)
    2. if col2 and Col3 are blank but col4 is non-blank then entire filtered rows copy 1 time only.
    3. if col2 is non-blank but col3 and col4 are blank then copy entire thing only for 3 times if Col6 is "Yes" else copy only for 2 times.
    4. if col2 and col3 are non-blanks but col4 is blank then if col6 is "Yes" copy filtered rows for 7 times else for "No" copy 6 times.
    5. if col2 and col4 are non-blanks but col3 is blank then if col6 is "Yes" then copy 4 times else for "No" copy those only 3 times.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by ashishadhib; 11-30-2021 at 11:05 AM.

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Filter based on a condition and copy paste to another sheet

    1- Pls post the "after" screenshot to see how the result look like. try to display the row and column index.
    2- attach an example WS to help the helpers save time.
    Quang PT

  3. #3
    Registered User
    Join Date
    11-03-2021
    Location
    India
    MS-Off Ver
    2010
    Posts
    6

    Re: Filter based on a condition and copy paste to another sheet

    Hi thank you for your reply, as mentioned i have attached the Sample data Work sheet in Sheet1 and Output in Sheet2. Thank you.

+ 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. How to use a For Loop to copy and paste to another sheet based on condition?
    By maym in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-15-2018, 10:31 PM
  2. Filter, Copy, Paste in a new sheet and give heading based on criteria
    By saravanan1981 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2016, 09:54 AM
  3. Filter copy paste data based on sheet name
    By kannan1847 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2015, 01:58 PM
  4. [SOLVED] Filter/Copy based sheet name paste non adjacent columns
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2014, 06:16 AM
  5. [SOLVED] Copy and paste (values) to another sheet based on condition
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-09-2013, 10:25 PM
  6. Macro to filter based on column heading then copy and paste to new sheet
    By macattackr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2012, 05:14 PM
  7. Copy/Paste from one sheet to another based on condition
    By TheTempest in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-16-2010, 01:13 PM

Tags for this Thread

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