+ Reply to Thread
Results 1 to 12 of 12

Copyin data from sheet to another if values are same

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Copyin data from sheet to another if values are same

    This is the code i use:

    [I
    Please Login or Register  to view this content.
    [/I]

    It selects similar values from column A from these sheets, and puts it into results sheet. In addition to this, what I need is to pick up the whole row from the sheet "Second". I have tried adding

    Worksheets("second").Range(d).EntireRow.Select


    after looking for similar values, but this causes error. I also need to pick up one more value from sheet "first" and add it to the last column in "results" sheet, but this is secondary problem..
    Last edited by arlu1201; 01-24-2013 at 09:49 AM.

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

    Re: Copyin data from sheet to another if values are same

    Please use code tangs on your code

    Please Login or Register  to view this content.
    Could be changed
    Please Login or Register  to view this content.
    Assuminng that you have ten rows to copy

    Please Login or Register  to view this content.
    Be warned: I have been using the find function for a number of times. If your data is small, it works fine, but with large it is very slow as the code looks at every single row on both sheets
    Last edited by AB33; 01-24-2013 at 06:53 AM.

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Copyin data from sheet to another if values are same

    May be something like this...

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


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copyin data from sheet to another if values are same

    Quote Originally Posted by AB33 View Post
    Please use code tangs on your code

    Please Login or Register  to view this content.
    Could be changed
    Please Login or Register  to view this content.
    Assuminng that you have ten rows to copy

    Please Login or Register  to view this content.
    Be warned: I have been using the find function for a number of times. If your data is small, it works fine, but with large it is very slow as the code looks at every single row on both sheets
    Thank you, there seems to be some issue, for this picks all the data from the first sheet. I tried to change sheets but at that point it prints only 2 rows, and there should be hundred (as sheet "first" has that many rows). Haven't yet been able to figure out

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

    Re: Copyin data from sheet to another if values are same

    Sir,
    Please do not reply with quote. It has not purpose, but clutters the space.
    Could you please attach your sample? As long as you can cope with the speed, we can improve the code, but need to test it on your sample.
    To attach a workbook, click advance, half way the page there is an attachment.

  6. #6
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copyin data from sheet to another if values are same

    Ok, here is similar sample with the original code.
    Attached Files Attached Files

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

    Re: Copyin data from sheet to another if values are same

    Sirpa,
    I can only find one row which matches on both sheets

    Please Login or Register  to view this content.
    Last edited by AB33; 01-24-2013 at 09:51 AM.

  8. #8
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copyin data from sheet to another if values are same

    Sorry my bad, in this one the second sheets data is in column B. Other wise the same. And i'm not looking for similar rows, only cells to match.

    In this case, sheet firts would have value ABC in some line. If the same value is in sheet second in some (other) line, I would need to copy that value, and rest of the sheet second's row, where this value is located. I hope this doesn't sound too confusing..

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Copyin data from sheet to another if values are same

    sirpaleena,

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

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

    Re: Copyin data from sheet to another if values are same

    Please see amended code # 7.
    I have found 62 rows matches
    I have inlcuded colouring to see which rows have matches, but can easily remove it.
    Try it and let me know

  11. #11
    Registered User
    Join Date
    01-24-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Copyin data from sheet to another if values are same

    It is working, some issues (not finding the match) were caused by empty spaces at the end of the cells. Works now, thank you!

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

    Re: Copyin data from sheet to another if values are same

    Please close now this thread if you are happy with the solution provided.
    Go to the top- right -hand side of this page, Choose "Thread Tools", select Solved from the drop down menu

+ 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