+ Reply to Thread
Results 1 to 56 of 56

Copy data from one workbook to another based on criteria

  1. #1
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Copy data from one workbook to another based on criteria

    Hi

    I hope you will help me with a code. It is really not that complicated I think, although not so easy to explain, but I will try.



    I have two workbooks. One source and one target. Both workbooks are similar but with different information.
    I want to copy information from Source workbook to Target workbook based on some criteria.

    Both workbooks will be open when doing this, so no need to add path to the location on disk.

    I have uploaded sample workbooks. The "Target example" sheet in Target workbook show how it will look like when the operation is done.




    The criteria is that if a value in column D in Target workbook matches a value in column D in Source workbook.




    If value in Column D match then:




    In the same row as the match in Source workbook, check if there is any value in Column F.

    If YES:

    Operation 1:
    Copy the cell value to Column F in Target workbook in the row where the matching number
    is in that workbook.

    Operation 2:
    Copy the cell value from Column E in Source workbook and Paste (overwrite) it in the matching cell in Target workbook.

    Operation 3:
    Add this text to Column G in Target Workbook: "Copied from Source workbook"


    If NO:

    Add this text to Column G in Target workbook: "Found in Source workbook, but no Remarks"





    If no match in Column D, add this text to column G in Target workbook: "Not found in Source workbook.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Copy data from one workbook to another based on criteria

    Hi, check my solution.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Best Regards,
    Maras.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Place this macro in a standard module in your source workbook and run it from there. Before you run the macro, you will have to re-format column D in the Target workbook so that it matches the format in column D of the source workbook. In column D in the Target workbook, you can see that in some of the cells you have a little green triangle in the upper left hand corner of the cell. I got rid of these green triangles by copying and pasting the values from column D of the source workbook. I have attached a copy of the revised Target workbook. I have also saved this workbook with an "xlsx" extension since it doe not contain any macros.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Thank you both!

    Mumps1: I got your code to work, however it missed Part number 53482 in line 4. Too complicated for me to find why the code would miss that

    maras_mak: Your code worked! I will have to try it out on more workbooks than only this sample to make sure it works like intended. I would like to ask if you would do a minor change to the code. I would like to fill the cells with colors instead using text in Column G. I tried to do it myself and I thought it would be straight forward to change the .Value with .Interior.Color, but it messed up everything

    Instead of text in column G, i would like these colors to fill the cell:

    "Not found in Source workbook" will be
    Interior.ThemeColor = xlThemeColorDark1
    Interior.TintAndShade = -0.249977111117893

    "Copied from Source workbook" will be
    Interior.ThemeColor = xlThemeColorAccent5
    Interior.TintAndShade = 0.599993896298105

    "Found in Source workbook, but no Remarks" will be
    Interior.Color = 7961087


    To be clear, no text in the cells in Column G, only fill the cell with colors. Is this possible?

    Thanks a lot for your help! I appreciate it!

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    I suspect the problem is caused by the formatting in column D as I mentioned in my previous post. Here is the revised code to address the color fill. I have attached a copy of the Target file with the results of the macro. If you have a large data set, the approach in this macro will be very fast as it uses arrays instead of looping through the sheet data.
    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Copy data from one workbook to another based on criteria

    goranimo, I think it's better to put the code in a 'Target' workbook.
    Look at the attachment.
    Does it give the expected results?
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Thanks to both of you! I got both codes to work now.

    I need to have the code in Source workbook as I have to use it on multiple target workbooks.

    I will do some more testing on target workbooks before I mark this tread as solved.

  8. #8
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Ok, so I stumbled upon a couple of problems.

    1.

    The file name of target workbooks are dynamic, which make it a problem when the code refer to a specific target workbook name.
    I don't know what the best solution is here. If I have the code in the Source workbook, then I can copy the target workbook name and past it to a cell in source workbook, and that cell can be linked in the code?
    Then I have to copy target workbook file name and paste it in a cell in source workbook every time, but that will be an ok solution if it will work.


    2.

    Your codes works beautifully based on my sample, but I found that the target workbooks have different variations of numbers in the cells. This will be a problem if the code only look for exact match.
    I've uploaded an example of how the part numbers may be listed in the target workbook.

    Some cells contain 2 different numbers. The cell is wrapped. I want the code to pick up any of these two numbers in the source workbook, as they may be listed with only one of the numbers in source workbook.

    Some cells contain the number + ":NOP". In source workbook, not all of the numbers are listed with ":NOP" in the end, and I want the code to pick up the number from source workbook
    regardless of ":NOP" or not.

    I understand if this is difficult, but if you have any ideas I would be very happy.

    I really appreciate your help!
    Attached Files Attached Files

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Can you attach an updated copy of the source workbook that contains Part Numbers that match the target file you posted in Post# 8?

  10. #10
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Mumps1:

    I've uploaded updated versions of Target and Source workbooks.

    I've included all eventualities that I can think of. In the Target workbook in Part Name column I have written what to look for in Source workbook just to make it easier to see.
    The text is the same in Source workbook, although in Upper Case to see if the code works and the information is copied to Target workbook.

    Please note that the Target workbooks will have Part Numbers stored as text as default. In Source workbook I can have whatever works best.
    Attached Files Attached Files

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Based on the information you placed in column E of the target workbook, I don't think it will be possible to do what you are asking. Where there are 2 part numbers in column D, sometimes you want to find the first one and sometimes the second one. Sometimes you want to include "NOP" and sometimes not. Sometimes you want to find both. Macros depend on patterns to do their work. There doesn't seem to be any pattern in what you want to do unless I misunderstood.

  12. #12
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Mumps: I understand, it's getting very complicated

    Anyway, when I tried to run your code in the samples I posted it seems like there are some errors.

    Row 3: Internal comments is marked red which is correct (There is nothing in remarks), but if there is match in part number it should also copy the part name, which it didn't.

    Row 6: Same problem as row 3.


    Any solution to this?

    Also, as I mentioned in post #8, the target workbook will vary What is the best solution to make it work? I tried to paste the Target workbook name in a cell in Source workbook and make the code pick up that, but it didn't work. I guess this is an opportunity, I just wrote the code wrong.
    HTML Code: 

  13. #13
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Quote Originally Posted by Mumps1 View Post
    Place this macro in a standard module in your source workbook and run it from there. Before you run the macro, you will have to re-format column D in the Target workbook so that it matches the format in column D of the source workbook. In column D in the Target workbook, you can see that in some of the cells you have a little green triangle in the upper left hand corner of the cell. I got rid of these green triangles by copying and pasting the values from column D of the source workbook. I have attached a copy of the revised Target workbook. I have also saved this workbook with an "xlsx" extension since it doe not contain any macros.

    Please Login or Register  to view this content.


    Hi Mumps.

    I am trying to make this work in an other workbook as well, but the data is in different columns. I tried to figure out this code to make the necessary adjustments, but with no luck.

    Could you please look at the attached Source and Target workbook and update the code so that it will work?


    Look up the Target workbook item numbers in Source (database) workbook. If there is match, then copy (overwrite) Description, Stocking Line and List Price.


    Any help will be appreciated!

    Thank you.Source.xlsxTarget.xlsx

  14. #14
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    .. forgot to mark thread unresolved..

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Could you please look at the attached Source and Target workbook
    I don't see the target workbook.

  16. #16
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Hi Mumps1, they are here both here: Capture.JPG

  17. #17
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    In which columns in the Target sheet do you want to place the following comments:
    "Copied from Source workbook"
    "Found in Source workbook, but no Remarks"
    "Not found in Source workbook."

  18. #18
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    I don't need those comments.

  19. #19
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Perfect. Thank you. Really appreciate your help!

  21. #21
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    You are very welcome.

  22. #22
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Quote Originally Posted by Mumps1 View Post
    You are very welcome.
    Hi Mumps.

    I've experiencing problems with this code when there is only 1 row with data in Target workbook. Is this possible to fix? Debug in bold below.

    Please Login or Register  to view this content.

  23. #23
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Thank you! Awesome.

  25. #25
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    My pleasure.

  26. #26
    Registered User
    Join Date
    04-17-2013
    Location
    Caguas, Puerto Rico
    MS-Off Ver
    2010
    Posts
    15

    Re: Copy data from one workbook to another based on criteria

    Hi Mumps.
    hope you are doing well.

    I am trying to make some changes to the code you share (see code below). I tried to figure out this code to make the necessary adjustments, but with no luck.
    My sheets (NewToAdd and FEB23) share column C, I’m trying to update column F in FEB23 when cells in both sheet C have the same record.

    Could you please look at the picture attached (I was unable to include the workbook, the system give me an error) NewToAdd and FEB23 workbook and update the code so that it will work? Also, let me know what make the different, I think is how you address the variants.
    Thanks in advance.

    Sub MatchData()
    Application.ScreenUpdating = False
    Dim dewsWS As Worksheet, srcWS As Worksheet, arr1 As Variant, arr2 As Variant, Val As String
    Set srcWS = ThisWorkbook.Sheets("Source")
    Set desws = Workbooks("Target.xlsx").Sheets("Target")
    Dim LastRow As Long
    arr1 = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 16).Value
    arr2 = desws.Range("B5", desws.Range("B" & Rows.Count).End(xlUp)).Value
    Set rnglist = CreateObject("Scripting.Dictionary")
    For i = 1 To UBound(arr1, 1)
    Val = arr1(i, 1)
    If Not rnglist.Exists(Val) Then
    rnglist.Add Key:=Val, Item:=i + 1
    End If
    Next i
    For i = 1 To UBound(arr2, 1)
    Val = arr2(i, 1)
    If rnglist.Exists(Val) Then
    If arr1(rnglist(Val) - 1, 3) <> "" Then
    desws.Range("F" & i + 4) = arr1(rnglist(Val) - 1, 3)
    desws.Range("J" & i + 4) = arr1(rnglist(Val) - 1, 16)
    desws.Range("M" & i + 4) = arr1(rnglist(Val) - 1, 12)
    End If
    End If
    Next i
    Application.ScreenUpdating = True
    End Sub

    Capture - Sheet1.JPG
    Capture - Sheet2.JPG
    Last edited by Ssammy; 02-08-2023 at 09:54 AM.

  27. #27
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Please start you own new thread. Include a link to this thread if you feel it is useful. Please use code tags when posting code. As well, it is hard to work with pictures. Please attach a copy of your file (de-sensitized if necessary. See the yellow banner at the top of the this screen for instructions on how to attach a file.

  28. #28
    Registered User
    Join Date
    04-17-2013
    Location
    Caguas, Puerto Rico
    MS-Off Ver
    2010
    Posts
    15

    Re: Copy data from one workbook to another based on criteria

    Thank, I will do

  29. #29
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Quote Originally Posted by Mumps1 View Post
    My pleasure.
    Hi again Mumps1. Sorry to bother you again, I have tried to figure out this myself. How can I change this code to add more criteria?


    Here the data will be copied from source to target based on criteria if cell value in column A in source matches cell value in column B in target.

    I want the exact same data to be copied, but I have 2 more criteria I would like to add in to the code.




    I really appreciate if you have the opportunity to look into this.

    Attachments: Target workbook, Source workbook and Criteria workbook (only for explanation)
    Attached Files Attached Files
    Last edited by goranimo; 02-15-2023 at 03:11 AM.

  30. #30
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    The link you posted doesn't work. Please follow the instructions in yellow at the top of this page to post an attachment.

  31. #31
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Mumps1: Sorry, I updated the post with attachments.

  32. #32
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Your source file does not contain any data in columns G and I and your target file does not contain any data in columns O and P. Please post updated files that contain data in those columns.

  33. #33
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Hi,updated with data.
    Attached Files Attached Files

  34. #34
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  35. #35
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Works beautifully!

    If there is data in Column B, O & P (all 3 of them) in Target workbook, but no match based on the criteria in Source workbook, could you add "Not Found" in column J?

    If no data in Column O or P in Target workbook, then do nothing. (like the code is now)

  36. #36
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    could you add "Not Found" in column J?
    Column J of which workbook?

  37. #37
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Oh sorry, Column J in Target.

  38. #38
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  39. #39
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Edit:

    It worked, however should only show "Not Found" if there is data in Column B, O & P in Target workbook AND no match based on the criteria in Source workbook.

    Now it shows "Not Found" even if there is no data in Column O & P.
    Last edited by goranimo; 02-22-2023 at 09:32 AM.

  40. #40
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  41. #41
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Thank you! I hope this was the last time I have to bother you with this.

    I greatly appreciate your help!

  42. #42
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    My pleasure.

  43. #43
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Please Login or Register  to view this content.

    Mumps1, sorry to bother you, again..

    After the last update i'm having this error if there is only data in cell B5 (or if no data in any cell in column B).

    Subscript out of range (error in bold in the code)

    If there are no data in column B I just want to let the code run finish without doing anything. I really appreciate if you could take a look at this.

  44. #44
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  45. #45
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Hi,

    It now worked if there is no data in B5, but I still get the Error if there is data in B5 (in Target) only.

  46. #46
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Which line of code is highlighted when you click Debug?

  47. #47
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    It is the line in bold in post #43. Line 7 from the bottom.

  48. #48
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Replace this line of code:
    Please Login or Register  to view this content.
    with this one:
    Please Login or Register  to view this content.

  49. #49
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Hmm, still the same error in the IF statement on bold below

    Please Login or Register  to view this content.

  50. #50
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Try:
    Please Login or Register  to view this content.

  51. #51
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    It works if there is only data in B5 IF Column B, O, P in Target matches A, G, I in Source.

    If I change B5 or O5 in Target so that it not matches A, G and I in source I get the same error.

    I'm sorry if you are getting tired of this

  52. #52
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Replace this line of code:
    Please Login or Register  to view this content.
    with this one:
    Please Login or Register  to view this content.

  53. #53
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    When I did this change I got no error, but I get "not Found" in column J for all numbers not found in Source workbook even if the criteria in post #35 is not met.

    However I can change the code back to what it was and just add a "-" in B6 if there is only data in B5. Then it will work

  54. #54
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    Sounds good.

  55. #55
    Forum Contributor
    Join Date
    04-11-2014
    Location
    Norway
    MS-Off Ver
    Office 365 version 2302
    Posts
    152

    Re: Copy data from one workbook to another based on criteria

    Thanks again.

  56. #56
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Copy data from one workbook to another based on criteria

    My pleasure.

+ 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 one workbook into another based on criteria
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-13-2017, 12:53 PM
  2. Copy Data to Another Excel WorkBook Based on Criteria Using VBA
    By bdrod in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 10-07-2016, 12:11 PM
  3. Replies: 2
    Last Post: 06-29-2016, 03:56 PM
  4. Copy and Paste Data from one Sheet to Other on different workbook based on Criteria
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2016, 03:25 PM
  5. Copy Data from workbook into another based on certain criteria
    By Rossko7226637 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-07-2015, 08:48 AM
  6. [SOLVED] Need code to copy data based on filter criteria to new workbook as save in a file location
    By msantucci in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-24-2015, 02:47 AM
  7. Copy Data to New Workbook based on Criteria
    By jimbean in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2008, 03:06 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