Copy Data From Worksheet to Another Worksheet

J

Joe K.

I would like a Excel VBA script to copy the data from Worksheet T1 to
Worksheet T2. Columns A and B uniquely identify the records for Worksheet T1
and Worksheet T2. I would like the script to populate Column K,L,M,and N from
Worksheet T2 the using the Columns C,D,E and F from Worksheet T1.

Please help me create this script.

Thanks,


Worksheet T1
Column A Column B Column C Column D Column E Column F
123 TENN 647 2389 IN 879
238 DALL 348 7148 OUT 1224
624 DENV 786 8909 IN 6478

Worksheet T2
Column A Column B Column K Column L Column M Column N
624 DENV
123 TENN
238 DALL

Desired Output: Worksheet T2
Column A Column B Column C Column D Column E Column F
624 DENV 786 8909 IN 6478
123 TENN 647 2389 IN 879
238 DALL 348 7148 OUT 1224
 
J

Joel

Try this code. I think you final results has the wrong column lettters. The
destination should b columns K,l,m,n


Sub Populate_T2()

With Sheets("T1")
T1RowCount = 1
Do While .Range("A" & T1RowCount) <> ""
Number = .Range("A" & T1RowCount)
City = .Range("B" & T1RowCount)

With Sheets("T2")
T2RowCount = 1
Do While .Range("A" & T2RowCount) <> ""
If (Number = .Range("A" & T2RowCount)) And _
(City = .Range("B" & T2RowCount)) Then

Sheets("T1").Range("C" & T1RowCount & ":F" & _
T1RowCount).Copy Destination:=.Range("K" & T2RowCount)
Exit Do
End If
T2RowCount = T2RowCount + 1
Loop
End With
T1RowCount = T1RowCount + 1
Loop
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top