You are here:

Excel/Formula or macro question

Advertisement


Question
Hi Tom

Could you help me with this new issue?  

I have a workbook which contains several worksheets.  One worksheet "Sheet2rng" contains a column  entitled "Group"  This column contains a list of different classes.  In a column entitled "name" will be the names of all of the students.

In another sheet called "SPtemplate" there is a cell "B1" where I might input the name of a class.  

When I input the name of the class, I would like all of the students in that class to populate another area of the worksheet "SPtemplate"  D1:D40.

Is this possible to do using formula?

Answer
Christoper Mitchell,

Yes, it can be done with an array formula.

=Index(name,Small(if(Group=SPTemplate!$B$2,Row(Group)),Row(A1)),1)

in D1 and entered with Ctrl+shift+Enter rather than just Enter since this is an array formula

then drag fill D1 down to D40

this is the raw formula.  It will produce errors once you go past the number of students in that class.  So if  you only have 20 students, D21:D40 would display #Value.  You can enclose the formula in IFERROR(formula,"") to avoid that.

I have assumed that Group and name are named ranges per your description.  If you just mean that is the text in row 1 of the sheet in the appropriate column (i.e. commonly called a column header), then in the formula they would have to be replaced with something like

Sheet2rng!$A$2:$A$500   

also, name and group should cover the same number of rows.

Or they could be column headers in a defined table but I would have to look at how to properly address those as I don't use defined tables.  

if you need more help than that, you would have to send a workbook to twogilvy@msn.com

--
Regards,
Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.