+ Reply to Thread
Results 1 to 14 of 14

Copy and Paste with certain criteria

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Copy and Paste with certain criteria

    Hello:


    Please refer to attached file.

    I have excel file with data from A1:T31.

    I need a VB macro or Formula to do the following:

    Need to check the value in column L.
    If value is greater then zero then copy corresponding cell from N:T in sheet2 as shown.

    In the attached example since L2 > 0 then i would need to copy and paste in Sheet2 at A2
    In the attached example since L3 = 0 then skip.
    In the attached example since L4 > 0 then i would need to copy and paste in Sheet2 at A3

    asn so on...

    Let me know if you have any questions.
    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy and Paste with certain criteria

    Hi Riz,
    Try the attached.
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    Works great, thank you so much.

    Riz

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy and Paste with certain criteria

    Riz,
    I forget to include a line on the code if you do not have visible filtered cells to copy. The amended code works better.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    Thank you so much for updated code and i have tried and this works great.
    I need 1 more favor.
    Need to modify the code so t give the total rows copied.
    i need this is field P6.


    Let me know if you have any questions.
    Thanks.

    Riz

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy and Paste with certain criteria

    Hi Riz,
    You mean sheet 2, P6.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    Yes, thank you so much.
    Will let you know if any further help is needed.
    Thanks

    Riz

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    I am trying to implement your code in my worksheet and for some reason, when i run the macro, excel closes.

    Please refer to attached file.
    I would really appreciate if you could look into and let me know if I need to make any further changes.

    Basically, I am creating excel file to print Pay check for employees.


    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy and Paste with certain criteria

    Hi Riz,
    My PC has keept crashing when I try to work on your sample. I am unable to delete or amend the sheets. As soon as I do something on sheets, excel crashes-5 times. It may be something to do with the link of sheets you have with other sheets. I need to my excel 2010

    I have put the code on the top. I assumed that you want to copy the data in colulmn B and columns are now streched to column V.
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33 and All:

    Its very strange why excel is crashing.
    I do not have any links from other workbook.
    Its also crashing at my end.
    Please have a look and let me know if you have solutions.
    Thanks
    Riz

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy and Paste with certain criteria

    It is possible some of the sheets have been corrupted. The simple solution is to copy each sheet in to new sheet, save it with a new name and then delete the culprit (Old book).

  12. #12
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    I will try that out and let you know later.
    Thanks a lot for your great help.
    Riz

  13. #13
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    I have tried with your instruction, still same result...excel closes/crashes.
    It looks like its something to do with VLOOKUp, since part of the Vlookup table is erased.
    I need to try something and need your help.

    Look at the your code below:

    Please Login or Register  to view this content.
    Here the line :

    Please Login or Register  to view this content.
    will be pasted at the end of previously stored data.
    I need overwritten.
    The max overwritten will be 30 rows.
    Lets say you have 4 employees with Net Pay >0 then those 4 records will start from "Sheet2", B1,B2,B3,B4.
    The other cell B5 thru B30 can be null.
    I think overwrite will solve my problem of clearing the cells.

    Let me know if you have any questions.
    Thanks.


    Riz

  14. #14
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: Copy and Paste with certain criteria

    Hi AB33:

    I believe i have solved the problem.
    I will contact you if further help is need.

    Thanks

    Riz

+ 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. Replies: 0
    Last Post: 10-29-2013, 09:38 AM
  2. [SOLVED] Copy and Paste with criteria
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 12:25 AM
  3. [SOLVED] Copy paste depending on certain criteria (VBA)
    By bonny24tycoon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2012, 07:59 AM
  4. Copy and Paste Based on Criteria
    By jadown in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2011, 04:14 PM
  5. Copy and paste from one sheet to another if the criteria met
    By wali in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-12-2009, 04:25 PM

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