Match data in two columns add rows to line up

Kim B

Board Regular
Joined
Jun 16, 2008
Messages
233
Office Version
  1. 365
Happy New Year to all.

I have two columns. I need to match the data in the columns and insert rows to end up across from each other. I apologize for the format, I can't seem to attach my data correctly. A match function with tell me there is a match between the two columns, but then I need the data to end up in the same row in both columns so I am thinking a macro might be needed.

Thank you

Mine Yours
Cust Nbr Cust Name Amount Cust Nbr Cust Name Amount

890111 Abc 5 750111 Battle 89
75000 Ionic 349 890111 Abc 54
5600011 ionic US 2789 75000 Ionic 762300
576011 Tesa 9872



Result


890111 Abc 5

750111 Abott 89
890111 Battle 54
75000 Ionic 349 7500 Ionic 762300
5600011 ionic US 2789
576011 Tesa 9872
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
xlmug,

Similar message received again with your link in your reply #11.

Click on the Reply to Thread button, and just put the word BUMP in the thread. Then, click on the Post Quick Reply button, and someone else will assist you.
 
Upvote 0
Dragging out an old post....

I'm using the following...edited from earlier post.
Code:
Sub AlignCustNbr()

Dim ws As Worksheet
Dim LR As Long, a As Long
Dim CustNbr As Range
Application.ScreenUpdating = False
Set ws = Worksheets("Sheet1")

LR = ws.Range("N" & ws.Rows.Count).End(xlUp).Row
ws.Range("N3:Y" & LR).Sort Key1:=ws.Range("N3"), Order1:=xlAscending, Header:=xlNo, _
  OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
  
LR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
ws.Range("A3:L" & LR).Sort Key1:=ws.Range("A3"), Order1:=xlAscending, Header:=xlNo, _
  OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Set CustNbr = ws.Range("A2:L" & LR)
a = 2

Do While CustNbr.Cells(a, 1) <> ""
  If CustNbr.Cells(a, 1).Offset(, 13) <> "" Then
    If CustNbr.Cells(a, 1) < CustNbr.Cells(a, 1).Offset(, 13) Then
      CustNbr.Cells(a, 1).Offset(, 13).Resize(, 12).Insert -4121
    ElseIf CustNbr.Cells(a, 1) > CustNbr.Cells(a, 1).Offset(, 13) Then
      CustNbr.Cells(a, 1).Resize(, 12).Insert -4121
      LR = LR + 1
      Set CustNbr = ws.Range("A3:L" & LR)
    End If
  End If
  a = a + 1
Loop
Application.ScreenUpdating = 1
End Sub

It works awesome and really appreciate the help. I'm curious if this could check a second column after the first for comparison. Right now it's comparing column A to N (employee ID). If this could also could compare column L and Y AFTER checking A and N.
So if A=N and L=Y, then leave it in one line. If A=N but L<>N then move it to the next line. Same with A<>N, move to the next line.

I can attach some example data if that helps. Thank you!!
 
Upvote 0
It works awesome and really appreciate the help. I'm curious if this could check a second column after the first for comparison. Right now it's comparing column A to N (employee ID). If this could also could compare column L and Y AFTER checking A and N.
So if A=N and L=Y, then leave it in one line. If A=N but L<>N then move it to the next line. Same with A<>N, move to the next line.

I can attach some example data if that helps. Thank you!!

andrewcrc,

1. What version of Excel, and, Windows are you using?

2. Are you using a PC or a Mac?


I would like more information. Please see the Forum Use Guidelines in the following link:

http://www.mrexcel.com/forum/board-announcements/127080-guidelines-forum-use.html


Because of the size of your data, screenshots will not be a good idea.

You can post your workbook/worksheets to the following free site (sensitive data changed), and provide us with a link to your workbook:

https://dropbox.com


3. And, can we have an additional worksheet (manually formatted by you), of what the results should look like?
 
Upvote 0
andrewcrc,

I have had problems in the past when attempting to download a zipped file, or, an Excel file with macros, with the xlsm file extension.

Please save your workbook as an xlsx file, and, repost on dropbox.
 
Upvote 0
3. And, can we have an additional worksheet (manually formatted by you), of what the results should look like?

andrewcrc,

Thanks for the new workbook.

Your workbook only contains Sheet1.

Site 1's raw data is in range A3:F19219

Site 2's raw data is in range N6:S18902

And, there are a lot of rows in both ranges that are blank?


Click on the Reply to Thread button, and just put the word BUMP in the thread. Then, click on the Post Quick Reply button, and someone else will assist you.
 
Upvote 0

Forum statistics

Threads
1,223,928
Messages
6,175,445
Members
452,642
Latest member
acarrigan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top