Clean Data Multiple Workbooks Varying Columns

*shudder*

Well-known Member
Joined
Aug 20, 2009
Messages
510
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

I am trying to combine data from multiple workbooks with differing number of columns and the data isn't in a table.

Examples of the type if data I an trying to combine:

Book1

No.1
NameName1
DoBDoB1
DepartmentDept1

Book2

No.1234
NameName1Name2Name3Name4
DoBDoB1DoB2DoB3DoB4
DepartmentDept1Dept1Dept2Dept3

I have what various videos about and spent a few hours looking at transpose and unpivot options to no avail.

Any guidance would be much appreciated.


Stuart
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I am looking to stack the columns so the result should look like this:

NameName1
DoBDoB1
DepartmentDept1
NameName2
DoBDoB2
DepartmentDept1
NameName3
DoBDoB3
DepartmentDept2
etc..

All of the individual 'names' are unique values.
 
Upvote 0
Hi, the way I would approach that would be something like this...

1.)Make two Queries which unpivot the first and second table. (So you would have Query1 result of unpivot of Table 1 and Query 2 result of unpivot of Table 2)
2.)Once you made the two tables append the data.
Add a conditional column which returns the ff: Name returns 1/ DoB returns 2/ Department 3 (naming it as "Card Sort") (if column name No. = "Name" Output 1 etc...)
After creating the conditional column sort your data first by attribute then by Card Sort (See screenshot as reference)
Then Add Column > Index column which begins with 1.

1.PNG


And then maybe have a filter like Index <=6 for Query 3
Then another filter which is >=7 for Query 4
(this is vaguely dividing your dataset into two)

Next would be adding another Index(2) for Query 3 and Query 4
Finally merge Query 3 and Query 4 using the newly created Index "Index(2)"

Hopefully this is fine for a solution.
 
Upvote 0
2.)Once you made the two tables append the data.
Add a conditional column which returns the ff: Name returns 1/ DoB returns 2/ Department 3 (naming it as "Card Sort") (if column name No. = "Name" Output 1 etc...)
After creating the conditional column sort your data first by attribute then by Card Sort (See screenshot as reference)
Then Add Column > Index column which begins with 1.

Sorry, I am lost on this bit. What is ff?

I can get the data from a single workbook with the following process:

1) Add Index
2) Unpivot Columns
3) I then have the attribute and index to associate the records i.e.

Attribute (column)IndexQuestionValues (unpivot)
(I tried creating a custom column concatenating these attribute/ index but I get an error)

How do I get this to apply across multiple sources (workbooks)?

I have about 150 workbooks and anything from 1 to 50 response columns. The only thing that is fixed is the question set at 62 rows.
 
Upvote 0
FF/Following

You could invoke a custom function to access each table/get data from file and tinker around it.

()=>

Something like a list of the excel files you want to extract, then invoking each file with the custom function. (i usually do this with hyperlinks though and not excel files)

 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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