+ Reply to Thread
Results 1 to 12 of 12

multiple sheets if column a and b have same value then copy entire row into new sheet

Hybrid View

myjebay1 multiple sheets if column a... 02-11-2014, 01:34 PM
JOHN H. DAVIS Re: multiple sheets if column... 02-11-2014, 03:42 PM
myjebay1 Re: multiple sheets if column... 02-12-2014, 11:24 AM
myjebay1 Re: multiple sheets if column... 02-17-2014, 05:19 PM
JOHN H. DAVIS Re: multiple sheets if column... 02-18-2014, 12:01 PM
myjebay1 Re: multiple sheets if column... 02-20-2014, 11:58 AM
JOHN H. DAVIS Re: multiple sheets if column... 02-20-2014, 12:23 PM
myjebay1 Re: multiple sheets if column... 02-20-2014, 01:36 PM
JOHN H. DAVIS Re: multiple sheets if column... 02-20-2014, 01:42 PM
myjebay1 Re: multiple sheets if column... 02-20-2014, 02:38 PM
JOHN H. DAVIS Re: multiple sheets if column... 02-20-2014, 03:11 PM
myjebay1 Re: multiple sheets if column... 02-20-2014, 04:09 PM
  1. #1
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    multiple sheets if column a and b have same value then copy entire row into new sheet

    hi everyone
    would like some help with this.
    have column a being an id and column b a date on multiple sheets.
    if there is a match anywhere in the sheets then the macros would copy the entire row and place the two lines of data next to one another in the same row on a new sheet.

    ex

    sheet 1

    mm2200 2/4/14 yes

    sheet 2

    mm2200 2/4/14 no

    sheet 3

    mm2200 2/4/14 yes mm2200 2/4/14 no


    thanks!!

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    Can you provide a sample with some data to test on?

  3. #3
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    Hi John!

    Thanks for getting back to me.
    I have attached three files, the first two is the source data, the 3rd is what the macros would produce.

    the macros is looking for a match in sheet1 columns a and b with sheet2 columns a and b, once a match is found it copies and pastes both rows and pastes adjacently into one row in the third file.

    Ideally, the macros would do this for all matches in columns a and b checking the source data against each other, when a match is found pasting both rows into the 3rd sheet.

    I have highlighted the example rows for ease of understanding.

    THANKS!!!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    hey john, let me know if you need anything else...would be a HUGE HELP!!

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    Maybe:

    Sub myjebay1()
    Dim i As Long
    Dim rcell As Range
    Dim ws As Worksheet
    Dim ws2 As Worksheet
    Dim ws3 As Worksheet
    Application.ScreenUpdating = False
    Set ws = Workbooks("acasi ex.xlsx").Sheets("Sheet1")
    Set ws2 = Workbooks("acasi ex2.xlsx").Sheets("Sheet1")
    Set ws3 = Workbooks("acasi what it should look like.xlsx").Sheets("Sheet1")
    ws.Activate
    Columns(1).Insert
    With Range("A2:A" & ws.UsedRange.Rows.count + 1)
        .Formula = "=CONCATENATE(B2,C2)"
        .Value = .Value
    End With
    ws2.Activate
    Columns(1).Insert
    With Range("A2:A" & ws.UsedRange.Rows.count + 1)
        .Formula = "=CONCATENATE(B2,C2)"
        .Value = .Value
    End With
    ws.Activate
    For i = Range("AK" & Rows.count).End(3)(2).Row To 2 Step -1
        Range(Cells(i, "AL"), Cells(i, "AS")).FormulaArray = "=VLOOKUP(A" & i & ",'[acasi ex2.xlsx]Sheet1'!$A$2:$I$218,{2,3,4,5,6,7,8,9},FALSE)"
    Next i
    With Range("AL2:AS" & ActiveSheet.UsedRange.Rows.count)
        .Value = .Value
        .Replace "#N/A", ""
    End With
    For Each rcell In Range("AL2:AL" & ActiveSheet.UsedRange.Rows.count + 1)
        If rcell.Value <> "" Then
        Range(rcell.Offset(, -36), rcell.Offset(, 7)).Copy ws3.Range("A" & Rows.count).End(3)(2)
        End If
    Next rcell
    Range("AL2:AS" & ActiveSheet.UsedRange.Rows.count).ClearContents
    Columns(1).Delete
    ws2.Columns(1).Delete
    Application.ScreenUpdating = True
    End Sub
    Based on your samples.

  6. #6
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    Wow! Thank you SO much! It works like a charm.
    So my VBA skills are moderate at best. I thought when I saw the code I'd be able to tweak it to apply to Eight different spreadsheets. That unfortunately has not been the case.
    Would you be able to walk me through it/be kind enough to come up with some code for it/want me to upload the other 6 spreadsheets?
    It would literally be the same task but with 8 spreadsheets instead of two.

    Thanks for all your help. You are a lifesaver.

    Best Wishes,

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    8 Worksheets? Or 8 Workbooks?

  8. #8
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    8 workbooks

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    Quote Originally Posted by myjebay1 View Post
    8 workbooks
    You want to compare each of those workbooks to this one?

    Workbooks("acasi ex.xlsx").Sheets("Sheet1")

  10. #10
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    ideally it would compare all 8 to one another. anytime there was a match by ptid and date in the 8 it would CUT(sorry i put copy earlier, but if we cut it, we can see which ones do not have a match in the other workbooks and address them as missing)and paste.
    therefore, if there were 6 matches it would take those 6 and place them in the new work book in a row, if there were 4 matches it would put those 4 in the same row, etc.

    THANKS!

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    That's a bit more than I can help you with.

  12. #12
    Registered User
    Join Date
    10-21-2011
    Location
    baltimore,md
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: multiple sheets if column a and b have same value then copy entire row into new sheet

    what if it were 8 worksheets? :/

+ 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 Rows to sheet if column value >40, multiple sheets
    By rlowe in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-04-2013, 06:08 PM
  2. Replies: 2
    Last Post: 10-08-2013, 02:58 PM
  3. [SOLVED] I need to search for a word on multiple sheets and copy the entire row to a new sheet
    By jkm750 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2013, 12:13 AM
  4. macro to copy column A from multiple sheets onto summary sheet
    By fabrecass in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2012, 05:46 PM
  5. If cells match from two sheets, copy entire row to new sheet function
    By Ckapp22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2012, 05:36 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