+ Reply to Thread
Results 1 to 16 of 16

Data Comparison and copy to other tab

  1. #1
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Data Comparison and copy to other tab

    I have a script that was created for a previous request but I am looking to modify it for new data. I have the spreadsheet (attached) and the code below. I am looking to place "Grid ID" numbers starting at B6 and below on the "Customer" tab. Then do a search on the "output" tab and if the "Grid ID" matches, then copy the contents from the "A"column to "Q" column on the "output" tab for that Grid ID and copy it to the "C" to "Q" colums on the corresponding Grid ID line on the "Customer" tab. I know the code is close but not sure what I am missing.

    <code>

    Option Explicit


    Sub nomatchnoty()

    Dim X, Z, i As Long, j As Long, n As Long, Y(), dic As Object

    With Worksheets("Customer")
    X = .Range("a6:Q" & .Range("A" & .Rows.Count).End(xlUp).Row)
    End With

    Set dic = CreateObject("scripting.dictionary")
    dic.comparemode = 1
    With dic

    For i = 1 To UBound(X, 1)
    If Len(X(i, 3)) Then
    .Item(X(i, 3)) = i
    End If
    Next
    End With

    With Worksheets("Output")
    X = .Range("a23:Q" & .Range("A" & .Rows.Count).End(xlUp).Row)
    End With

    ReDim Y(1 To UBound(X), 1 To UBound(X, 2))

    With dic
    For i = 1 To UBound(X)
    If Len(X(i, 3)) Then
    If .exists(X(i, 3)) Then
    For j = 4 To UBound(X, 2)
    Y(.Item(X(i, 3)), j - 3) = X(i, j)
    Next
    End If
    End If
    Next
    End With

    With Worksheets("Customer")
    .Range("C6:Q" & .Rows.Count).ClearContents
    .Range("C6").Resize(i - 1, UBound(Y, 2)) = Y
    .Columns.AutoFit
    End With
    End Sub
    <code>
    Attached Files Attached Files
    Last edited by stangz71; 01-18-2015 at 04:02 PM.

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

    Re: Data Comparison and copy to other tab

    stangz71,
    Please wrap you code with code tags. You should edit the above code and put it on tags.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    AB33

    I will make sure to do this next time but would also like to know if there is anyway to remove the blank space on the D column so the remaining data gets added to the D column?
    Last edited by stangz71; 01-19-2015 at 06:37 PM.

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

    Re: Data Comparison and copy to other tab

    In which sheet?

  5. #5
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    The customer sheet because it writes something to the C column and then adds a blank space to the D column and then writes to the E column. If it's not possible, no worries, just wondering if it could be done, thanks in advance.

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

    Re: Data Comparison and copy to other tab

    It is possible, just need to understand.
    The reason for writing blank in column D is because you have empty in column B in sheet output.
    The code copies from column A to Q and the second column to be copied is column B and it is blank.

  7. #7
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    So if you can copy A, skip "B" and do C:Q, that would be great.

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

    Re: Data Comparison and copy to other tab

    You have also other empty columns in A-Q, but the attached skips column B only.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    That's the winner, thanks again for all your help.

  10. #10
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    AB33

    Wondering if you are still around and can help me change the spreadsheet that you assisted me with in 2015?

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

    Re: Data Comparison and copy to other tab

    Yes, I am still around, but not as active as in the past. Please attach a sample with a desired output.

  12. #12
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    I attached a sample of what I am looking for and added some "Possible Future Column" because I may need to pull in other columns in the future so if you can make it so I can adjust the amount of columns I pull into the "DD_Inventory" tab I would appreciate it, thanks in advance.
    Attached Files Attached Files

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

    Re: Data Comparison and copy to other tab

    The last column is L. See if this works for you.

  14. #14
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    That works great thanks for your help but for future reference what would I need to do to extend it beyond column "L"?

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

    Re: Data Comparison and copy to other tab

    If others remain the same, just need to change column L to what ever you want. If you struggle, just drop me a PM

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    07-19-2011
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    73

    Re: Data Comparison and copy to other tab

    Thanks again for taking the time to help me out.

+ 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. Help!!! how can i copy contents from Tab2 into Tab1 using a same cell comparison
    By merQrey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-30-2014, 06:22 AM
  2. [SOLVED] Copy between soreadsheets based cell comparison
    By rfaris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2013, 03:02 PM
  3. macro copy/paste lists data from multiple sheets to one comparison sheet
    By johnnieboi89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2011, 04:22 PM
  4. How do I copy a function for comparison but keep first cell value.
    By N'wester in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-22-2005, 12:06 AM
  5. [SOLVED] Copy data between 2 Excel for comparison
    By Boba in forum Excel General
    Replies: 1
    Last Post: 02-18-2005, 10: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