Using VBA / INDEX / VLOOKUP to return a whole row on a different spreadsheet

thedicewoman

New Member
Joined
Aug 27, 2013
Messages
2
Hello there,

I've trawled the internet and can't seem to get just the right answer for my query: I hope someone here can help.

I have built a report with a front page, a calculations page, a clean data page and an export data page. The Clean Data page picks up what the user exports into the export data page and runs some neat little formulas to remove any erroneous records. It has all of the raw data I need to build the Front Page.

On the Front Page, I'd like to include some tables which will read the Clean Data page and return records (whole rows, around 6 columns) dependant on certain parameters.

So, lets say I want all records (rows) displayed on the Front Page which have 'UK' included in the 'Project Location' column on the Clean Data page. Is there a formula I can use to return:
a) more than one record
b) the entire row of that record?

The aim is for any user to simply enter the Export Data and have a quickly-produced front page report with certain parameneters set to return highlighted records.

Any advice you can give on this would be most appreciated: I am not shy in using VBA for a solution, as long as I can build in a user-friendly 'Generate Report' button. I have 2007.

Many thanks
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi and welcome to the forum,

Here is one possible solution you can try with this example setup:

Excel 2013
ABCD
1Project Location:UK
2Count:3
3
4Column index123
5Row indexProject LocationProject TypeProject Number
61UKA1
72UKB2
85UKE5

<tbody>
</tbody>
Sheet1
Excel 2013
ABC
1Project LocationProject TypeProject Number
2UKA1
3UKB2
4FranceC3
5GermanyD4
6UKE5

<tbody>
</tbody>
Sheet2
The associated formulas for Sheet1 are as follows.

In B2 enter:

=COUNTIF(Sheet2!A$2:A$6, B1)

In A6 (using CTRL-SHIFT-ENTER rather than just ENTER as this is an array formula) and drag down as far as required:

Code:
=IF(
    ROWS(A$5:A5) > B$2,
    "",
    SMALL(
      IF(
        Sheet2!A$2:A$6 = B$1,
        ROW(Sheet2!A$2:A$6) - ROW(Sheet2!A$2) + 1),
      ROWS(A$5:A5)))

In B6 enter and drag across and down as far as required:

=IF($A6 = "", "", INDEX(Sheet2!$A$2:$C$6, $A6, B$4))

Note that an easier approach might just be to use a PivotTable or filters on the original data assuming your users would be comfortable with that.

If you need additional criteria in Sheet1, e.g. like this:

Excel 2013
ABCD
1Project Location:UK
2Project Type:A
3Count:2
4
5Column index123
6Row indexProject LocationProject TypeProject Number
71UKA1
82UKA2

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Then you can use the following in B3 and A7 (and down).

In B3 enter:

Code:
=COUNTIFS(
    Sheet2!A$2:A$6, B1,
    Sheet2!B$2:B$6, B2)

In A7 (using CTRL-SHIFT-ENTER rather than just ENTER as this is an array formula) and drag down as far as required:

Code:
=IF(
    ROWS(A$6:A7) > B$3,
    "",
    SMALL(
      IF(Sheet2!A$2:A$6 = B$1,
      IF(Sheet2!B$2:B$6 = B$2,
        ROW(Sheet2!A$2:A$6) - ROW(Sheet2!A$2) + 1)),
      ROWS(A$6:A7)))

If you want further criteria continue the same pattern adding more conditions as required.
 
Last edited:
Upvote 0
HI there,

Thanks very much for your swift reply. I will give this a go: on first glance it seems it will do the trick!

Cheers
 
Upvote 0

Forum statistics

Threads
1,216,124
Messages
6,128,997
Members
449,480
Latest member
yesitisasport

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