+ Reply to Thread
Results 1 to 19 of 19

Copy rows with specific text in specific column into specific sheet

  1. #1
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Post Copy rows with specific text in specific column into specific sheet

    Hi All
    I have a problem, which I'm sure one of you out there can help me with .

    I have my workbook with 4 sheets, which consist of one typing-sheet and 3 backup sheets.

    The macro I need should do the following process, when I run it:
    1. Copy all the rows from the typing sheet “Typing” where the cells in column N is = “Vundet” into the next empty row in the sheet “Vundet” and then clear the copied rows from the typing sheet “Typing”.
    2. Copy all the rows from the typing sheet “Typing” where the cells in column N is = “Tabt” into the next empty row in the sheet “Tabt” and then clear the copied rows from the typing sheet “Typing”.
    3. Copy all the rows from the typing sheet “Typing” where the cells in column N is = “Fravalgt” into the next empty row in the sheet “Fravalgt” and then clear the copied rows from the typing sheet “Typing”.
    4. If the cells in column N is empty = do nothing.


    An example in the attached file:
    Row 7, 9 and 10 should be copied into the sheet “Vundet”, and the rows should be cleared in the typing sheet.
    Row 8, 11 and 12 should be copied into the sheet “Tabt” and the rows should be cleared in the typing sheet.
    Row 13, 14 and 15 should be copied into the sheet “Fravalgt” and the rows should be cleared in the typing sheet.


    Sample1.xlsx


    Sincerely regards
    Jens/Valemaar
    Last edited by Valemaar; 08-24-2014 at 05:21 AM.

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

    Re: Copy rows with specific text in specific column into specific sheet

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Mabye you are right, but unfortunately, I'm not completly sure how to use it ?

    Do I just insert your code in a module and run?

    /Valemaar
    Last edited by Valemaar; 08-21-2014 at 05:22 PM.

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

    Re: Copy rows with specific text in specific column into specific sheet

    Yes. Just place it in a standard module and run.

  5. #5
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    It does not work quite as intended. Nothing happens when I run it .

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

    Re: Copy rows with specific text in specific column into specific sheet

    Check after row 404 on each sheet. Typing should be cleared.

  7. #7
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Ohhh nice work!!!

    However, the values ​​can not be inserted into the first empty row after row 6 instead of row 404?

    Also, is it possible that the formatting from the typing sheet is not cleared from the typing sheet?

    Great job !!

  8. #8
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Also the macro should do nothing with the row if the cell in column N is empty or have any other text og number. I can see that the macro fails if I'm writing anything but; "Vundet", "Tabt", or "Fravalgt" column N.

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

    Re: Copy rows with specific text in specific column into specific sheet

    Try:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Yes, now the formatting in the typing sheet is staying untouched = Perfect!

    But there is still two problems:
    1. The copied rows should be inserted into the first empty row after row 6 instead of row 404.
    2. If the cell in column N not contain the word "Vundet", "Tabt" or "Fravalgt" the macro should skip that row (do nothing).

    In the attachment you see that the macro is failing .

    Sample1.xlsm

    /Valemaar

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

    Re: Copy rows with specific text in specific column into specific sheet

    Try:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Yes now there the second problem left .

    2. If the cell in column N not contain the word "Vundet", "Tabt" or "Fravalgt" the macro should skip that row (do nothing).

    /Jens

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

    Re: Copy rows with specific text in specific column into specific sheet

    Ok try:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Now we are almost there . But the I can see that the copied rows are not put into the next empty row on the backup sheets.

    An example: If row 7, 8, 9 in the sheets "Vundet", "Tabt" or "Fravalgt" already have values in them, the macro overwrites these rows, instead of placeing the copied rows into the next empty row. In this example it would mean the macro should place the copied rows in row 10 and forward.


    But you are doing a hell of god job


    /Valemaar

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

    Re: Copy rows with specific text in specific column into specific sheet

    Try:

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Sorry to say it, but It still overwrites the data that is already in the 3 backup sheets when it paste the copied values. If it helps you could mayby program it to look at column A, and look for the first empty cell there?

    Example:
    Is Cell "A7" empty = no = Look in Cell "A8"
    Is Cell "A8" empty = no = Look in Cell "A9"
    Is Cell "A9" empty = no = Look in Cell "A10"
    Is Cell "A10" empty = no = Look in Cell "A11"
    Is Cell "A11" empty = YES = insert the copied rows in row 11 and down


    /Valemaar

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

    Re: Copy rows with specific text in specific column into specific sheet

    Unfortunately that's what the code tells it too do. However, the formatting on your spreadsheet for some reason makes it difficult to address those concerns. I've attempted to get around it but can't. Sorry I can't help you further.

  18. #18
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Okay.. Would it help if I removed the formatting on the backup sheets or is it the formatting on the Typing sheet that is the problem?

  19. #19
    Registered User
    Join Date
    11-05-2013
    Location
    DK
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Copy rows with specific text in specific column into specific sheet

    Maybe I can get this code to work insted:

    Please Login or Register  to view this content.
    But then you can maybe help me by showing how I get the code to clear the values after they have been copied into the backup sheets?

    /Jens

+ 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] Copy a specific range to another sheet adding all the workdays for a specific time period
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-05-2014, 02:19 AM
  2. [SOLVED] Macro to copy specific data from one WB to specific cells in another WB based on specific
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 11:05 AM
  3. Copy rows with values in specific column to first empty row in specified sheet
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2013, 08:29 PM
  4. [SOLVED] Macro code to Copy specific rows into specific columns
    By macrofan2012 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-11-2012, 11:24 AM
  5. Replies: 0
    Last Post: 09-17-2012, 11:10 AM

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