+ Reply to Thread
Results 1 to 41 of 41

Look for Text and Copy Value to another Sheet

  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Red face Look for Text and Copy Value to another Sheet

    Hi everyone

    First of all I have to say that this is a GREAT Forum. Lots of Information and material to learn
    I have tried to find out how to make my idea possible but I had no Chance
    So I ask you to help me
    I upload a workbook with the description what I want to do
    I hope i did a good explanation because my english is not the best one

    Kind regards
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    "The file is corrupted, can not open it"

  3. #3
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Ok, i saved it again and upload it
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    Sorry! The same problem.

  5. #5
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hello

    I opened my workbook on two machines with no Problems. I have no idea what happened. But no Problem
    Maybe you can help me with the code i wrote


    Please Login or Register  to view this content.
    This code works but i want to use this code for the range 10:2 to 10:16
    But when i write the code for each cell then itīs a very big code
    I tried to find out how to get this code a little smaller with the "for_each_cell_in_range" function, but I had no luck
    Can you give me a little help please?

    Thanks!!!

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

    Re: Look for Text and Copy Value to another Sheet

    No, please save it with save as a new name and in new location. In the mean time, I am working on your code.

  7. #7
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    OK, here is the new saved workbook
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    Same problem!
    Could you please contact the admin if the issue is with my PC, or your data? Could you ask someone else if they have the same problem.
    I have adjusted the first part of your code, but I need to test it on the sample data as you have numbers not letters on your cells range.

  9. #9
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Ok, I uploaded it now from another machine
    There are two workbooks. One for the code and one with the my first question

    Thanks
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    I managed to open the first attachment "workbook with codes". Are all the data on this book?

  11. #11
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hi,
    there are some data in this workbook. I would be very happy if you can help me with making the code a Little smaller for the range 10:12 to 10:16. If i have a starting Point then i can write the code by myself (I hope so :-) )

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

    Re: Look for Text and Copy Value to another Sheet

    This is my intake of your data.
    You are testing for column "AJ". If one is true you are returning some times rows 9 column 2, other times row 9 and 4.
    You are copying in to sheet DN column 5 which is column E, but not sure which is the first row in column E. Is it the next empty row? Please explain in more details.

  13. #13
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hi,

    If in one of the cells in sheet "Tabelle 1" range B10 to S10 contains a value of the list in AJ then

    if "B1" then go up 1 column (because there are the values to copy), same row, and go right to cells. copy These two values an paste it into DN 1 cells B5 and D5
    if "B1A" then go up 1 column, same row and copy to DN 1 cell B5
    Target for searching "B1A" is DN 1 cell B5
    Target searching "B1E" is DN 1 cell C5
    Target searching "P1" is DN 1 cell D5 and E5 (like "B1")
    Target searching "P1A" is DN 1 cell D5
    Target searching "P1E" is Dn 1 cell E5
    Target searching "B2" is DN 1 cells F5 and G5 (like "B1")
    Target searching "B2A is DN 1 cell F5
    Target searching "B2E" is DN 1 cell G5

    The Command Button called "Übernehmen" is to start the macro
    The other CommandButton called "Dienstnehmer 1" is to Change the sheet
    The CommandButton called "Command" was just a try from me to copy another timeline to cell B9 to S9

    I hope my Explanation was a Little better

    Thanks a lot for spending your time

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

    Re: Look for Text and Copy Value to another Sheet

    Sorry! It is not clear to me.
    The code you have referrers to rows 10, but row 10 is blank.
    "If in one of the cells in sheet "Tabelle 1" range B10 to S10 contains a value of the list in AJ then"
    But rows B10-S10 are blank. You mean row 9. Row 9 has time data, but column AJ has letters, so you can not find dates in column AJ.
    How can you find time 7:00 in column AJ?
    It would be easier for you to attach your desired result on spread sheet, as this might be easier than to explain in words.

  15. #15
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hi
    the values for the cells are from the dropdownlist in each cell. the list is on AJ
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    Okay! Will let you know if I have further issues.

  17. #17
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Thanks a lot

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

    Re: Look for Text and Copy Value to another Sheet

    It took me a while to understand your request. The attached gives you a good start.
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Thanks a lot! I will try it tomorrow as fast as possible!

  20. #20
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    WOOOWWWWWW! Thank you soooooooo much! What a great help!!!!!

  21. #21
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hi, itīs me again

    I worked on the code and it works great. But i have a Problem. If i run the macro then the data are shown in the sheet "DN 1". BUT when i do some changes and run the code again, then the data are not in the right column and row. Can you please help me modify the code that changes on sheet "Tabelle1" row (B)10 only effects on the sheet "DN 1" range B5 to G5? "Tabelle 1" row (B)11 only effects on sheet "DN 1" range B6 to G6 and so on.
    Thanks again

  22. #22
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Can I do something like
    Dim blabla as Range
    Range = (B10:S10)

    for example

  23. #23
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Can I do something like
    Dim blabla as Range
    Range = (B10:S10)

    for example

  24. #24
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    This did not work :-(

    Please Login or Register  to view this content.

  25. #25
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Please help

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

    Re: Look for Text and Copy Value to another Sheet

    You need to post the sample where you are using the code, showing where the code fails.

  27. #27
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Hi,

    I upload the file where i wanted to change the code. As you can see the macro works now for all changes in
    range B5 to G5 ("DN 1") when i put in same data in "Tabelle 1" range B10 to S10.
    But how can i make this code better that it will do the changes on sheet "Tabelle 1" range B16 to S16
    only on "DN 1" range B6 and G6 and so on.
    Thanks a lot
    Attached Files Attached Files

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

    Re: Look for Text and Copy Value to another Sheet

    You have change my original code which includes a case for the next row 16. You are now looping through a single range Select Case .Cells(10, i)
    I did another case for row 16, but has now been removed.

  29. #29
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    I did this because when i made changes then the data has not been on the right place in "DN 1". they where on the next empty rows in "DN 1".
    That is not good when I want to make some changes.

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

    Re: Look for Text and Copy Value to another Sheet

    If you want to paste in to range B6 and G6, how can you do it with out next empty row? Is not it B6 is the next row after B5?You have removed the next empty row from the code.

  31. #31
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    What I mean is
    i put in some data in "Tabelle 1" and run the macro. The data are shown in "DN 1" on the right place (B5 to G5 and B6 to G6)
    Then i change the data in "Tabelle 1" and run the macro again. And now the data are not in range B5 to G6 and so on.
    They start at B7.

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

    Re: Look for Text and Copy Value to another Sheet

    They start at B7.
    This is then the next empty row once B5 and B6 are filled.

  33. #33
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Yes, BUT i want have the data from "Tabelle 1" range B10 to S10 only in "DN 1" range B5 to G5
    The data from "Tabelle 1" range B16 to S16 only in "DN 1" range B6 to G6
    The data from "Tabelle 1" range B22 to S22 only in "DN 1" range B7 to G7
    because when i want make changes in "Tabelle 1" then the data should be at the right day in DN 1

    Something happened now. I copied the code for 6 days ("Tabelle 1" B10 B16 B22 B28 B34)
    Then i deleted the data manually in DN 1 so that all cells are clear and run the macro again
    Then i got an error 1004 Method range for object _worksheet failed
    What does this means?

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

    Re: Look for Text and Copy Value to another Sheet

    I run the code again on the attached I sent you and did not get any error. You need to use the same code and show me which line does give you an error. Since we are using select case if your rows are out 1, you will get a different result. You can use if statement instead, but looks cumbersome and still need to loop through again.

  35. #35
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Here is what I did.
    I copied the code and wrote it for "Tabelle 1" B16, B22, B28 and B34
    The changes from B16 B22 and B28 where placed right in "DN 1" when i run the macro multiple times.
    But when i did the code for B34 and run the code multiple times then the data where in DN 1 not on the right
    place.
    You can see it on my upload
    Attached Files Attached Files

  36. #36
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Then, when i delete the all the data in DN 1 and run the macro again I got the error.

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

    Re: Look for Text and Copy Value to another Sheet

    The reason you keep getting an error is the code could not find the next empty Row (LR) in sheet Dn1. I have now changed it. I have also included a separate code which uses fixed next empty cell, which would not give you any error if the code could not find next empty row (LR).
    Attached Files Attached Files

  38. #38
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    Thanks a lot again!!! Works great!!!!!

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

    Re: Look for Text and Copy Value to another Sheet

    Moosmahna,

    You are welcome!

    Could you please now close (Mark) this thread as solved? Go to the top right-hand side of this page, choose "Thread Tools" from the menu, then select "solved" from the drop down menu.

  40. #40
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Austria
    MS-Off Ver
    Excel 2016
    Posts
    169

    Re: Look for Text and Copy Value to another Sheet

    One last question :-)
    Is it possible to write a macro that Looks for colours and then gets the data?
    for example:
    "Tabelle 1" Cells B10 to E10 are green. The first green cell ("B10") is "B1A" and the last green cell ("E10") is
    "B1E"

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

    Re: Look for Text and Copy Value to another Sheet

    This is new request which does not relate to the original thread.
    Please close this thread and start a new thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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