Solved

How to extract data from Excel Sheet

Posted on 2011-02-13
13
763 Views
Last Modified: 2012-05-11
Hello Excel Experts,

I need a bit of help with the attached Excel file.

I have a list with thousands upon thousands of entries (the first three sample on the list). What I  would like to do is to create some type of formula to 'pull out' the line that has the subtotal and write this line to another sheet. For example, in the sample list I would need Smith, John on row (9), Jones, Susan on row (17), and Johnson, Jerry on line (25) to pull out and be written on a separate sheet like this:

Smith, John Average  82.42857143  Atwater HS  6 9999999999
Jones, Susan Average 91.42857143  Atwater HS  7 8888888888
Johnson, Jerry Average 74.28571429 Atwater HS 8 9999999999

In respective cells A, B, C, D, E where:

Student Name is in column A
Grade Average is in column B
School in column C
GradeLevel in column D
StudentID in column E

...of the next sheet, say, sheet 2.

Hope this makes sense. Doing this would save me a ton of manual work

Thanks again!  Kind of need this right away so offering max points.
List.xlsx
0
Comment
Question by:shogun5
  • 5
  • 3
  • 2
  • +2
13 Comments
 
LVL 23

Accepted Solution

by:
Michael74 earned 500 total points
ID: 34885807
I couldn't think of a formula to do it so here is a macro

Note you need to change the lines

   Set list = ThisWorkbook.Sheets("List")
   Set collated = ThisWorkbook.Sheets("Sheet1")

to reflect the actual names of the sheets

Michael
Sub collateData()
   Dim i As Long, lastrow As Long, outRow As Long
   Dim list As Worksheet, collated As Worksheet
   
   Set list = ThisWorkbook.Sheets("List")
   Set collated = ThisWorkbook.Sheets("Sheet1")
   
   lastrow = list.Range("A" & Rows.Count).End(xlUp).Row
   outRow = 2
   
   For i = 2 To lastrow
      If Right(list.Range("A" & i).Value, 7) = "Average" Then
         list.Range("A" & i & ":E" & i).Copy
         collated.Range("A" & outRow).PasteSpecial xlPasteValues
         Application.CutCopyMode = False
         outRow = outRow + 1
      End If
   Next
   
End Sub

Open in new window

List.xlsm
0
 

Expert Comment

by:pradeepprahllad
ID: 34885822
you can use pivot table.  Attaching solution List.xlsx
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34885833
Hello,

without any VBA, you can click a cell in the table, then click Data>Group>Auto Outline.

The outline symbols will appear at the left of the table. Click on the 2 to the left of the column labels and there's your list.

You can select the list, hit F5, click Special and tick "Visible cells only", then copy and paste to another sheet.

cheers, teylyn
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 23

Expert Comment

by:Michael74
ID: 34885843
@teylyn

Very nice answer

Michael
0
 

Author Closing Comment

by:shogun5
ID: 34885845
Awesome! Worked Great! Thanks!
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34885847
Here's a screenshot:


shot.png
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34885850
To actually extract the data into the second sheet with formulae, you just need one helper column with a 1 in the first row and this formula copied down
=MATCH(INDEX(List!A:A,F1+1)&" Average",List!A:A,0)
Note: This does require that the line with Average spell the name exactly the same way as the lines above. See example:
list.xls
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34885851
Oops. Too late.
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34885858
Shogun5,

did you see all the other suggestions before you accepted the solution? Sometimes it's worth waiting for more than one answer to see what others come up with. As far as I can tell, experts have given four different solutions, and each of them work.

I don't begrudge Michael74 the solution or the points. He's deserved them. I just want to advise you not to make too hasty a decision when it comes to accepting solutions. VBA may work, but if there is a formula or user interface alternative, like pivot table, this is always faster and more efficient than VBA.

cheers, teylyn
0
 

Author Comment

by:shogun5
ID: 34885860
Teylyn,

Thanks. Yes normally I wait but boss needed this NOW. So needed to run with the first solution.

Cheers!

0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34885877
Your boss needs a new job. :-) His attitude seems a lot like Dilbert's pointy-haired version. Does he look like it, too?
0
 

Author Comment

by:shogun5
ID: 34885910
Yes!
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34885968
shogun5,

maybe you are in the market for a new job soon, too! :-))

All the best. Hope your boss is happy with the solution supplied by Michael and EE.

cheers, teylyn
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question