Data Extraction from a single large table with formulae or VBA (VLOOKUP? MATCH? INDEX)

seattletimebandit

Board Regular
Joined
Apr 11, 2013
Messages
69
Hello all,


I've got some data in a table (346 rows, 13 columns). I need to pull specific data from the range of cells based on the left-most column/rows (SampleID) and the column headers (Chemical Name).


Truncated table:


SampleIDDateBenzeneEthylbenzenem,p-Xyleneo-XyleneTolueneGasolinecis-1,2-DCEPCEtrans-1,2-DCETCEVC
Sample11/10/140.0252 U0.3080.03280.0252 U0.0252 U6.30 U
Sample21/10/140.02470.04880.09530.03310.0224 U1790.0209 U0.03400.0209 U0.0209 U0.0021 U
Sample31/10/1429.515349663.02.719,5800.0177 U0.0177 U0.0177 U0.0177 U0.0018 U
Sample41/10/140.04510.1180.1460.0234 U0.0234 U2330.0257 U0.2160.0257 U0.0257 U0.0026 U
Sample51/10/140.3442.932.230.06080.0213 U235
Sample61/10/140.0195 U0.0292 U0.03990.02140.0195 U4.87 U

<tbody>
</tbody>



The output would be:


Sample11/10/14
Benzene0.0252 U
Ethylbenzene0.308
m,p-Xylene0.0328
o-Xylene0.0252 U
Toluene0.0252 U

<tbody>
</tbody>

Sample21/10/14
Benzene0.0247
Ethylbenzene0.0488
m,p-Xylene0.0953
o-Xylene0.0331
Toluene0.0224 U

<tbody>
</tbody>

Sample31/10/14
Benzene29.5
Ethylbenzene153
m,p-Xylene496
o-Xylene63.0
Toluene2.71

<tbody>
</tbody>


etc.




The output tables will be used as an overlay on an AutoCad map of a contaminated site with each ouput table pointing (with and arrow) to a monitoring well where the sample was collected.


I thought I could do this with VLOOKUP, but I'm not finding it to be workable. It would be nice to have several output tables be created for each SampleID, and also changing up the Chemical Name, either by a drop-down box to "build" the output table, one SampleID at a time, or choosing X number of Sample ID's and generating as many tables as the user wants. Either in the same worksheet of a new worksheet.


Thanks!


stb
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Have you tried building a pivot table with this? Put the sample ID as your report filter, your chemical columns as the rows, and the date as the column.
 
Upvote 0
KB,

I did try, but I'm not well versed in using them. However, with your guidance as to what goes where, I'll give it a go. Thanks!
 
Upvote 0
I tried playing around with it. Here's what I found worked best.
SampleID in the Report Filter
Date in the Column Labels
Your chemicals in the Values Section. When you do this, you'll need to do a couple things. First, click on the drop down and select Value Field Settings. Change the Summarize value field to Sum, then change the Custom Name to the chemical with a space after the name (so Excel doesn't give you an error). In the Column Labels section should now be a Values selection under Date. Click and drag that over to Row Labels.

I'd recommend pulling out any labels after the data in the table (like the U's). Pivot tables aren't fans of text values.
 
Upvote 0
KB,

That worked as far as the format goes, but the data is all zero's.

SampleIDSample1
Date
Data1/10/14Grand Total
Benzene 00
Ethylbenzene 00
Toluene 00
m,p-Xylene 00
o-Xylene 00

<colgroup><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Sheet1, A:M, houses the source data with headers in the first row.

Sheet2

Sample11/10/2014
Benzene0.0252 U
Ethylbenzene0.308
m,p-Xylene0.0328
o-Xylene0.0252 U
Toluene0.0252 U
Gasoline6.30 U

<tbody>
</tbody>

A1: Sample1

B1, just enter:
Rich (BB code):
=VLOOKUP(A1,Sheet1!$A$2:$B$7,2,0)

A2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(INDEX(Sheet1!$C$1:$M$1,SMALL(IF(1-(INDEX(Sheet1!$C$2:$M$7,  MATCH($A$1,Sheet1!$A$2:$A$7,0),0)=""),  COLUMN(Sheet1!$C$1:$M$1)-COLUMN(Sheet1!$C$1)+1),ROWS($A$2:A2))),"")

B2, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IFERROR(INDEX(Sheet1!$C$2:$M$7,
  MATCH($A$1,Sheet1!$A$2:$A$7,0),
  SMALL(IF(1-(INDEX(Sheet1!$C$2:$M$7,
  MATCH($A$1,Sheet1!$A$2:$A$7,0),0)=""),
  COLUMN(Sheet1!$C$1:$M$1)-COLUMN(Sheet1!$C$1)+1),
  ROWS($A$2:A2))),"")
 
Last edited:
Upvote 0
Hey Aladin,

I entered the formulas two the correct cells on sheet 2, hit CSE, and I can see the formulas with braces, but no data. For the VLOOKUP formula I get #NA (Value not available error).

Thoughts?

stb
 
Upvote 0
Hey Aladin,

I entered the formulas two the correct cells on sheet 2, hit CSE, and I can see the formulas with braces, but no data. For the VLOOKUP formula I get #NA (Value not available error).

Thoughts?

stb

There was some IE trouble while replying. Not sure whether the formulas stayed intact thru multiple edits. Hence recap below...

Sheet1, A:M, with headers in row1.

Sheet2

A1: Sample1 (a sample of interest)

B1, just enter:
Rich (BB code):
=VLOOKUP(A1,Sheet1!$A$2:$B$7,2,0)

A6, control+shift+enter and copy down:
Rich (BB code):
=IFERROR(INDEX(Sheet1!$C$1:$M$1,
  SMALL(IF(1-(INDEX(Sheet1!$C$2:$M$7,MATCH($A$1,Sheet1!$A$2:$A$7,0),0)=""),
  COLUMN(Sheet1!$C$1:$M$1)-COLUMN(Sheet1!$C$1)+1),ROWS($A$2:A2))),"")

B6, control+shift+enter and copy down:
Rich (BB code):
=IFERROR(INDEX(Sheet1!$C$2:$M$7,MATCH($A$1,Sheet1!$A$2:$A$7,0),
  SMALL(IF(1-(INDEX(Sheet1!$C$2:$M$7,MATCH($A$1,Sheet1!$A$2:$A$7,0),0)=""),
  COLUMN(Sheet1!$C$1:$M$1)-COLUMN(Sheet1!$C$1)+1),ROWS($A$2:A2))),"")

Here is the workbook that implements the set up described above:
https://dl.dropboxusercontent.com/u/65698317/seattletimebandit%20data%20extraction.xlsx
 
Upvote 0
Thanks Aladin. I got it to work after downloading your spreadsheet. I actually have 347 rows to column Q, so I changed the cell refs in your formula. I created a Data Validation list to choose the SampleIDs which works well (instead of copying/pasting into Cell A1). The one bust if found was that some Sample ID's weren't analyzed for BTEX, so the cells are blank, however, when I choose a SampleID that does not have data in the BTEX cells, the formula skips those blanks and calls the cells that do have data (i.e., data for Gasoline, Oil, and other compounds populate my little table that contains the formula).

Is there a way for the formula to reference the blank cells and not skip over them (somekind of IsNULL function)?

stb
 
Upvote 0
Thanks Aladin. I got it to work after downloading your spreadsheet. I actually have 347 rows to column Q, so I changed the cell refs in your formula. I created a Data Validation list to choose the SampleIDs which works well (instead of copying/pasting into Cell A1). The one bust if found was that some Sample ID's weren't analyzed for BTEX, so the cells are blank, however, when I choose a SampleID that does not have data in the BTEX cells, the formula skips those blanks and calls the cells that do have data (i.e., data for Gasoline, Oil, and other compounds populate my little table that contains the formula).

Is there a way for the formula to reference the blank cells and not skip over them (somekind of IsNULL function)?

stb

Would you illustrate the issue referring to the source data of which we have n exhibit in post #1?
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

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