+ Reply to Thread
Results 1 to 7 of 7

Loop to find data in a worksheet and copy into a different worksheet.

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    11

    Thumbs up Loop to find data in a worksheet and copy into a different worksheet.

    Hi Everyone,

    So yet again my lack of VBA skills is causing me trouble, even though i'm very sure it's the quickest way to do what I want.

    I have a workbbok with 8 sheets

    sheet 1- 7 are for customers, and contain details of the date they used a certain product and the amount they used
    sheet 8 is the price of the product on any given day since the beginning of 2010.

    what I need is for code to look at the date a customer used a product and then find the corresponding price on that date.
    And copy that price into the customers sheet. column 3
    I need this to loop until the end of the customers data and then move on to customer 2 ... 3 .... etc

    I have attached a sample of the workfile for reference.

    Any help would be amazingly welcome.

    Thanks.

    Attached Files Attached Files
    Last edited by emily_k8_lewis; 10-29-2013 at 06:45 AM. Reason: Solved

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    Hi you could use this code to loop through all cells and return the values.
    However i cant for the life of me remember why this does not work.
    Its to do with you having tables.
    if you done away with the tables and all ranges were formatted the same way then this should work.

    your date formats are not the same between customer & price sheet that is also causing a problem.

    Please Login or Register  to view this content.
    Last edited by Sean Thomas; 10-28-2013 at 01:51 PM. Reason: error in code
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    10-02-2013
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    Hi Sean,

    Thanks for the reply, I changed my data so it's not in tables anymore
    I also made sure the dates and prices we all formatted correctly as dates and numbers.
    The code still doesnt seem to work for me...

    the results of the vlookup return an #N/A

    Any idea why this might be?

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

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    Emily,
    I have also looked at your data and was going to write you a solution, but I always struggle with dates in excel.
    The dates in the tables are not equal to the dates in price tab. Test it yourself. Look at the first tab-customer 1, row 2 ("A2") is not equal to what appears to be the same date as in tab price, row 1202, 15/04/2013 ("A1202")

  5. #5
    Registered User
    Join Date
    10-02-2013
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    Hi,

    I coreccted all the formatting differences and still dont be able to get it to work.
    Not quite sure what the problem is.
    I've uploaded a different workbook with all of the new formatting

    Once again all of everyones help is really appreciated

    =]
    Attached Files Attached Files

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

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    Dates in excel are nightmare, least to say. I think the problem is still there. Sean's code should work if your dates match.
    Last edited by AB33; 10-29-2013 at 11:30 AM.

  7. #7
    Registered User
    Join Date
    10-02-2013
    Location
    london, england
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Loop to find data in a worksheet and copy into a different worksheet.

    yer, i can see the problem now...i think the dates within the customer sheets are actually saves as text and i cant seem to convert them into numbers so it might be a manual thing,
    i changes some of them manually and ran the code from Sean it worked perfectly thanks

    =]

+ 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 data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-21-2012, 04:02 AM
  2. Copy data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2012, 02:49 AM
  3. Auto-find and copy data from one worksheet to another
    By dooray in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-12-2012, 02:47 PM
  4. Loop through Worksheet and copy data into a templated worbook.
    By DDmonk in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-22-2011, 12:06 PM
  5. Copy Data between sheets with a worksheet loop
    By wjsok85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2010, 07:51 AM

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