How to carry over the values of a column in 1 workbook to another?

exceltm

New Member
Joined
Apr 5, 2010
Messages
32
I have 2 separate workbooks. I want to carry/copy one column in workbook A to workbook B, but only carry/copy over that one column, the values in the "status" column. Since some employees are removed and some are added, I can't simply copy and paste the entire "status" column from workbook A to B. I want to use column A as the unique identifier, then copy the values in the status column from workbook A to B, but to copy only for the employees that still exist in workbook 2. From workbook 1 to 2, employee number 13 is not longer present, so that entire row for employee 13 shouldn't carry over into workbook 2. I've highlighted in red what needs to be carried/copied over from workbook 1 to 2.

For example, here is the sample dataset from the 2 workbooks:

8DALLASTX
12SHREVEPORTLA
13METAIRIELA
19HARTFORDCT
20BATON ROUGELA
23OMAHANE
29WATERBURYCT
33JACKSONVILLEFL
35OMAHANE
49WATERBURYCT
workbook 2
8
DALLASTX
12SHREVEPORTLA
19
HartfordCT
20BATON ROUGELA
23OMAHANE
29WATERBURYCT
33JACKSONVILLEFL
35OMAHANE
49WATERBURYCT
55New HavenCT

<colgroup><col style="mso-width-source:userset;mso-width-alt:3185;width:67pt" width="90"> <col style="width:48pt" width="64" span="2"> <col style="mso-width-source:userset;mso-width-alt:3384;width:71pt" width="95"> <col style="width:48pt" width="64"> </colgroup><tbody>
[TD="width: 90"]workbook 1
[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 95"][/TD]
[TD="width: 64"][/TD]

[TD="class: xl67"]employee[/TD]
[TD="class: xl65"]CITY[/TD]
[TD="class: xl65"]State[/TD]
[TD="class: xl68"]SALES[/TD]
[TD="class: xl69, align: right"] status
[/TD]

[TD="class: xl63, align: right"]$30,835[/TD]
[TD="class: xl64, align: right"] 1
[/TD]

[TD="class: xl63, align: right"]$71,638[/TD]
[TD="class: xl64, align: right"] [/TD]

[TD="class: xl63, align: right"]$245,013[/TD]
[TD="class: xl64, align: right"] 3 [/TD]

[TD="class: xl63, align: right"]$181,049[/TD]
[TD="class: xl64, align: right"] [/TD]

[TD="class: xl63, align: right"]$2,166,385[/TD]
[TD="class: xl64, align: right"] 1 [/TD]

[TD="class: xl63, align: right"]$24,132[/TD]
[TD="class: xl64, align: right"] m
[/TD]

[TD="class: xl63, align: right"]$937,589[/TD]
[TD="class: xl64, align: right"] [/TD]

[TD="class: xl63, align: right"]$21,980[/TD]
[TD="class: xl64, align: right"] 1 [/TD]

[TD="class: xl63, align: right"]$3,066,541[/TD]
[TD="class: xl64, align: right"] [/TD]

[TD="class: xl63, align: right"]$240,774[/TD]
[TD="class: xl64, align: right"] m [/TD]

[TD="class: xl67"]employee[/TD]
[TD="class: xl65"]CITY[/TD]
[TD="class: xl65"]State
[/TD]
[TD="class: xl68"]SALES[/TD]
[TD="class: xl69"]status[/TD]

[TD="class: xl63, align: right"]$42,184[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$47,845[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"][/TD]
[TD="class: xl64"][/TD]

[TD="class: xl63, align: right"]$252,426[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$3,332,213[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$34,241[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$1,402,102[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$28,294[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$4,839,064[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$487,642[/TD]
[TD="class: xl64"] [/TD]

[TD="class: xl63, align: right"]$33,670[/TD]
[TD="class: xl64"] [/TD]

</tbody>
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about
Code:
Sub exceltm()
   Dim Ws1 As Worksheet, Ws2 As Worksheet
   Dim Cl As Range
   
   Set Ws1 = Workbook("Book1.xlsm").Sheets("sheet1")
   Set Ws2 = Workbook("Book2.xlsm").Sheets("sheet2")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Cl.Offset(, 4).Value
      Next Cl
      For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, 4).Value = .Item(Cl.Value)
      Next Cl
   End With
End Sub
Change Workbook & worksheet names to suit.
Both workbooks need to be open.
 
Last edited:
Upvote 0
You can use PowerQuery
Merge table from workbook2 to table from workbook1 by employee then expand Table column in result QueryTable with status only, then load to sheet

workbook1 can be opened or closed - doesn't matter
 
Upvote 0
You can use PowerQuery
Merge table from workbook2 to table from workbook1 by employee then expand Table column in result QueryTable with status only, then load to sheet

workbook1 can be opened or closed - doesn't matter

I'm using MS Excel 2013 from MS Office Professional Plus 2013. There are about 8000 rows in my spreadsheet table.
Could you please dumb this down for me, as I tried your suggestion first but encountered some roadblocks. There are a few missing steps. For example, I had to first download the Power Query add-on, which I now have loaded.

I clicked on Power Query | Merge, but when it opened the merge box, it said, "No preview is available. There are currently no queries that can be merged."

Merge by employee?
 
Upvote 0
workbook1 - change range to Excel Table (Ctrl+T)
workbook2 - change range to Excel Table (Ctrl+T)

from workbook2 Data - New Query - From file (table from workbook1)
select your table -edit - close&load - as connection
select any cell on table workbook2 - Data - From Table

now you've two tables loaded into PowerQuery Editor and you can use Merge Queries from PQ menu

Excel Power Query (Get & Transform) Tutorial for Beginners
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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