Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Extracting Data from 2 cells into 1

Trying to find median for a list of grades.
Each Column has a grade and below each row has the # of exams the student
has received that grade.

4.0 3.5 3.0 2.5
Student 1 2 1 1 2

How can I have Excel pull out: 4.0, 4.0, 3.5, 3.5, 2.5, 2.5 from the table
above? We are trying to avoid having to type it out...we want to simply put
the # of times that grade was received and then have Excel list the data
individually in cells so we can generate a median value. Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,311
Default Extracting Data from 2 cells into 1

Based on the data you've provided, you might try:

=LEFT(REPT(A1&", ",A2)&REPT(B1&", ",B2)&REPT(C1&", ",C2)&REPT(D1&",
",D2),LEN(REPT(A1&", ",A2)&REPT(B1&", ",B2)&REPT(C1&", ",C2)&REPT(D1&",
",D2))-2)

However, if you have more columns, then you'll need to adjust the formula.

HTH,
Paul

"DaveKTLC" wrote in message
...
Trying to find median for a list of grades.
Each Column has a grade and below each row has the # of exams the student
has received that grade.

4.0 3.5 3.0 2.5
Student 1 2 1 1 2

How can I have Excel pull out: 4.0, 4.0, 3.5, 3.5, 2.5, 2.5 from the table
above? We are trying to avoid having to type it out...we want to simply
put
the # of times that grade was received and then have Excel list the data
individually in cells so we can generate a median value. Thank you!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Extracting Data from 2 cells into 1

I'd use a UDF (a macro???).

Is that ok?

If yes:

Option Explicit
Function WeightedMedian(ScoreRng As Range, CtrRng As Range) As Variant

Dim ScoreArr() As Double
Dim myCell As Range
Dim rCtr As Long
Dim iCtr As Long
Dim WhichScore As Long

'some minor checking
If ScoreRng.Areas.Count _
And CtrRng.Areas.Count = 1 Then
'ok
Else
WeightedMedian = "One area each!"
Exit Function
End If

If (ScoreRng.Columns.Count = 1 _
Or ScoreRng.Rows.Count = 1) _
And (CtrRng.Columns.Count = 1 _
Or CtrRng.Rows.Count = 1) Then
'ok
Else
WeightedMedian = "Each Range must have one row or one column"
Exit Function
End If

If ScoreRng.Cells.Count = CtrRng.Cells.Count Then
'ok
Else
WeightedMedian = "Mismatched cell count"
Exit Function
End If

ReDim ScoreArr(1 To Application.Sum(CtrRng))

WhichScore = 0
For Each myCell In CtrRng.Cells
WhichScore = WhichScore + 1
For rCtr = 1 To myCell.Value
iCtr = iCtr + 1
ScoreArr(iCtr) = Application.Index(ScoreRng, WhichScore)
Next rCtr
Next myCell

WeightedMedian = Application.Median(ScoreArr)
End Function


You'd use it like this:
=weightedmedian($B$1:$E$1,B2:E2)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=weightedmedian($B$1:$E$1,B2:E2)

DaveKTLC wrote:

Trying to find median for a list of grades.
Each Column has a grade and below each row has the # of exams the student
has received that grade.

4.0 3.5 3.0 2.5
Student 1 2 1 1 2

How can I have Excel pull out: 4.0, 4.0, 3.5, 3.5, 2.5, 2.5 from the table
above? We are trying to avoid having to type it out...we want to simply put
the # of times that grade was received and then have Excel list the data
individually in cells so we can generate a median value. Thank you!


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Extracting Data from 2 cells into 1

If all you really need is just the median and you dont have too many high #s
in the
try for example for a 7 max #
=MEDIAN($A$1:$D$1,IF($A$2:$D$21,$A$1:$D$1),IF($A$ 2:$D$22,$A$1:$D$1),IF($A$2:$D$23,$A$1:$D$1),IF($ A$2:$D$24,$A$1:$D$1),IF($A$2:$D$25,$A$1:$D$1),IF ($A$2:$D$2,$A$1:$D$1))
entered as an array (contol-shift-enter)
another short hand method is to sort the data by the scores
add a helper column with cumilative total for # and look for # equal to or
just above total/ 2

"DaveKTLC" wrote:

Trying to find median for a list of grades.
Each Column has a grade and below each row has the # of exams the student
has received that grade.

4.0 3.5 3.0 2.5
Student 1 2 1 1 2

How can I have Excel pull out: 4.0, 4.0, 3.5, 3.5, 2.5, 2.5 from the table
above? We are trying to avoid having to type it out...we want to simply put
the # of times that grade was received and then have Excel list the data
individually in cells so we can generate a median value. Thank you!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting text from cells frosterrj Excel Worksheet Functions 6 December 18th 06 07:25 PM
Extracting Comma Seperated data into individual Cells Rmcnaught Excel Discussion (Misc queries) 2 July 18th 06 09:04 PM
Extracting Data for .Txt Files By Unique Field Data La Excel Discussion (Misc queries) 3 July 17th 06 01:30 PM
extracting text from cells famdamly Excel Discussion (Misc queries) 11 February 27th 06 12:19 AM
Extracting certain information from cells RobMack Excel Worksheet Functions 9 February 15th 06 02:37 AM


All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"