Copy column data after last row on matching of heading

gsgurpreetsingh501

New Member
Joined
Jan 7, 2016
Messages
12
Problem is to copy the column data from one sheet to other sheet (after last row) on matching of the column heading.
In the below sheet, Name is matching in both the sheets. So matching on "Name" basis, the entire "Name" column in Sheet 1 has to be copied to the end of Sheet2 Name column.

Sheet1:
S.NoDateweightName
14/3/201670John
24/3/201675Andrew
34/3/201667Gill
44/4/201680Macmillan

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>

Sheet2:
S.NoNameDays
1Brian2
2Neil5
3Kim10

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Result of Sheet2:
S.NoNameDaysDuration (Days)
1Brian22
2Neil55
3Kim1010
John
Andrew
Gill
Macmillan

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Possibly you can try something like the below code...

Rich (BB code):
Sub FindIt()
    Dim myCol As Long, myconst As String

    myconst = Sheets("Sheet2").Range("B1").Value

    With Sheets("Sheet1")
        myCol = .Rows(1).Find(What:=myconst, After:=.Cells(1, .Columns.Count), LookIn:=xlValues, LookAt _
                        :=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column
        .Range(.Cells(2, myCol), .Cells(.Cells(Rows.Count, myCol).End(xlUp).Row, myCol)).Copy _
                        Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp)(2)
    End With

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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