PC Review


Reply
Thread Tools Rate Thread

Copy Data From Worksheet to Another Worksheet

 
 
=?Utf-8?B?Sm9lIEsu?=
Guest
Posts: n/a
 
      6th Nov 2007

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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      6th Nov 2007
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

"Joe K." wrote:

>
> 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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy/pasting data into a worksheet and then sorting worksheet Pierrette T Microsoft Excel Programming 0 11th Nov 2009 03:23 AM
Copy data from one worksheet and paste into another worksheet stockton12 Microsoft Excel Programming 3 30th Mar 2008 09:40 PM
Copy data in multiple worksheet tabs into one worksheet Bob Microsoft Excel Programming 2 15th Feb 2008 03:01 PM
copy from B worksheet to A worksheet with NO repeated data =?Utf-8?B?dGlrY2h5ZV9vbGRMZWFybmVyNTc=?= Microsoft Excel Misc 1 29th Sep 2006 06:56 PM
copy data in a cell from worksheet A to worksheet B =?Utf-8?B?cmFqZXNo?= Microsoft Excel Misc 1 21st Feb 2006 07:40 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:09 AM.