Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Tots
Sep 3, 2007

:frogout:

ShimaTetsuo posted:

Yes, pivot tables will do what you want. If it didn't come out correctly on one example, it may have to do with some bad labeling on your part, like different spellings (or extra spaces) for the same logical category in column A, or confusion between numbers being recognized as actual numbers or as strings.

In your example, do you expect the sum corresponding to A=2 to be 6, or 11? Depending on how your source data is formatted and how you import it into Excel, "02" may automatically be parsed to the number 2, and you'll get 11. Otherwise you may get 6 for 2, and 5 for "02" separately.


In my example Column B would be the ID column and Column A would be the column to be summed based on column B. Idk what exactly was up with my small set of test data, but it seems to be corrected I guess. It still makes me nervous though using a large dataset that I can't easily proof.

Adbot
ADBOT LOVES YOU

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Tots posted:

This should be easy, but I can only find solutions if I want to define the criteria manually which I can't.

Say I have a large data set with two columns. Column A has some number and column B has an ID. How can I sum all values in column A that match ID n? The only thing I found through googling involved manually defining criteria.

E.G.

code:
A........B
12.......2
24.......1
02.......5
44.......5
102......2
2........6
12.......1
42.......2
05.......7
44.......8
Sum all numbers in column A that correspond to number 2 in column B etc... My dataset is much larger and more complex than this, but this should be a good example of what I need.

E: Okay, this seems to (sort of) work based on the recommended pivot tables. Although in one of the first test data sets I tried it in there was a number that didn't work out to what it was supposed to. I checked it several times (it was a small test dataset) and it definitely didn't add up for some (sum hah) reason. In all the datasets I tested afterwards it worked fine though.

Have you tried =sumifs()

ShimaTetsuo
Sep 9, 2001

Maximus Quietus

Tots posted:

In my example Column B would be the ID column and Column A would be the column to be summed based on column B. Idk what exactly was up with my small set of test data, but it seems to be corrected I guess. It still makes me nervous though using a large dataset that I can't easily proof.

Ok, I misread but the point still stands (in reverse): do you expect the sum for B=5 to be 46? Because depending on how you import it, it may keep "02" as a string and you will get 44 instead.

greasyhands
Oct 28, 2006

Best quality posts,
freshly delivered
edit: deleted, I just figured this out.

greasyhands fucked around with this message at 21:30 on Apr 14, 2014

Tots
Sep 3, 2007

:frogout:

ShimaTetsuo posted:

Ok, I misread but the point still stands (in reverse): do you expect the sum for B=5 to be 46? Because depending on how you import it, it may keep "02" as a string and you will get 44 instead.

I see what you're saying. Those are just numbers I made up. The real dataset I'm using is normalized.

FAN OF NICKELBACK
Apr 9, 2002
That is some pretty timely thread activity! I have to (have to) make a pivot table. I hate pivot tables though and like a jerk refused to learn their ins and outs because my first experience with them was lame.

My initial instinct was to use a collection linked to a dynamically data validated change event with keen conditional formatting and some already written VBA to create tables and graphs etc., so how can I still get that same usability from a pivot table because I'm bad at them :( does anyone have a really in depth pivot table tutorial that goes beyond the basics?

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

FAN OF NICKELBACK posted:

That is some pretty timely thread activity! I have to (have to) make a pivot table. I hate pivot tables though and like a jerk refused to learn their ins and outs because my first experience with them was lame.

My initial instinct was to use a collection linked to a dynamically data validated change event with keen conditional formatting and some already written VBA to create tables and graphs etc., so how can I still get that same usability from a pivot table because I'm bad at them :( does anyone have a really in depth pivot table tutorial that goes beyond the basics?

ExcelIsFun on YouTube has tons of videos. Here's one on slicers and Pivot Tables https://www.youtube.com/watch?v=zgt7SdrYJqg

Kraus
Jan 17, 2008
Question:

I am putting this formula into a spreadsheet:

=($H$110-H2)^2

How do I make it so that the "H2" part changes the "2" to the row the formula finds itself in?

Thanks in advance.

Toe Rag
Aug 29, 2005

This seems to work.

=($H$110-(INDIRECT(CONCATENATE("H",ROW()))))^2

Kraus
Jan 17, 2008

Toe Rag posted:

This seems to work.

=($H$110-(INDIRECT(CONCATENATE("H",ROW()))))^2

It does! Thank you!

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Kraus posted:

Question:

I am putting this formula into a spreadsheet:

=($H$110-H2)^2

How do I make it so that the "H2" part changes the "2" to the row the formula finds itself in?

Thanks in advance.

You shouldn't have to make any change. The $ in a cell address prevents it from changing. So the $H$110 will always point to the same cell no matter where you copy and paste it to. H2 will change columns and rows as your paste cell moves columns and rows. So if you initially have the formula in A1 and paste it into B2 the resulting formula would be =($H$110-I3)^2 because you moved right 1 column and down 1 row.

melon cat
Jan 21, 2010

Nap Ghost
Bar chart question.

Let's say I had custom colouring to each bar. One's red. One's blue, etc. All custom colouring. Is there any way to make Excel "remember" my bar chart colouring if the data changes and the categories shift positions?

I'm asking because I have to re-colour my bar charts whenever the data changes. Just wondering if there was a means of avoiding this.

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

melon cat posted:

Bar chart question.

Let's say I had custom colouring to each bar. One's red. One's blue, etc. All custom colouring. Is there any way to make Excel "remember" my bar chart colouring if the data changes and the categories shift positions?

I'm asking because I have to re-colour my bar charts whenever the data changes. Just wondering if there was a means of avoiding this.

You could do it with a macro.

Here's an example of someone looping through the series (lines on a line graph, or your bars). http://stackoverflow.com/questions/21165581/vba-looping-through-all-series-within-all-charts

You could modify that to include lines checking the series name and if it matches "X" make the bar/line blue.

Here's the series object members from MSDN.
http://msdn.microsoft.com/en-us/library/office/ff840677%28v=office.15%29.aspx

Total Meatlove
Jan 28, 2007

:japan:
Rangers died, shoujo Hitler cried ;_;
Say you've got a dataset that looks like;

code:
X 0 1 2 3 4 5 6 7 8 9 10
Y 1 2 3 4 5 6 5 4 3 2 1 
and you've shown it on a line graph. Is there any way to make a trendline that measures (and importantly forecasts) from only the first five 'X' positions, but still shows the entire line graph at the same time?

ShimaTetsuo
Sep 9, 2001

Maximus Quietus

Total Meatlove posted:

Say you've got a dataset that looks like;

code:
X 0 1 2 3 4 5 6 7 8 9 10
Y 1 2 3 4 5 6 5 4 3 2 1 
and you've shown it on a line graph. Is there any way to make a trendline that measures (and importantly forecasts) from only the first five 'X' positions, but still shows the entire line graph at the same time?

You can add another series to the graph which consists of only the first five points, add a trendline and set the "forward" option to however many periods, then hide the markers from the new series.

Alternatively, use the TREND array function which allows you to set "known_y's" and "known_x's" to the first five points, then set "new_x's" to all of your x's, then just plot the result.

melon cat
Jan 21, 2010

Nap Ghost

Old James posted:

You could do it with a macro.

Here's an example of someone looping through the series (lines on a line graph, or your bars). http://stackoverflow.com/questions/21165581/vba-looping-through-all-series-within-all-charts

You could modify that to include lines checking the series name and if it matches "X" make the bar/line blue.

Here's the series object members from MSDN.
http://msdn.microsoft.com/en-us/library/office/ff840677%28v=office.15%29.aspx
Wow. It's a lot more involved than I anticipated, but I'll give it a shot. Thanks!

Total Meatlove posted:

Say you've got a dataset that looks like;

code:
X 0 1 2 3 4 5 6 7 8 9 10
Y 1 2 3 4 5 6 5 4 3 2 1 
and you've shown it on a line graph. Is there any way to make a trendline that measures (and importantly forecasts) from only the first five 'X' positions, but still shows the entire line graph at the same time?
Just want to make sure I understand what you're trying to do. When you say that you want the trendline to "shows the entire line graph at the same time", you're saying that you want the trendline to show the first five X-values, but span across the entire line graph. Is that right?

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

melon cat posted:

Wow. It's a lot more involved than I anticipated, but I'll give it a shot. Thanks!

Sorry, just realized another option is to create a separate data table which then uses lookups to populate the series values. That way the series always has the same name and just the values change. Example below would always keep Hat as series 1 (which you could color Red) and then update the dates and sales amounts as the underlying data changes.

code:
Product | =min(date)                                                    | =B1+1                                                         | =C1+1
Hat     | =sumifs(Data[Sales],Data[Product],$A2,Data[[Sales Date]],B$1) | =sumifs(Data[Sales],Data[Product],$A2,Data[[Sales Date]],C$1) | =etc
Shoes   | =sumifs(Data[Sales],Data[Product],$A3,Data[[Sales Date]],B$1) | =sumifs(Data[Sales],Data[Product],$A3,Data[[Sales Date]],C$1) | =etc
Belts   | =sumifs(Data[Sales],Data[Product],$A4,Data[[Sales Date]],B$1) | =sumifs(Data[Sales],Data[Product],$A4,Data[[Sales Date]],C$1) | =etc
This is probably easier. Just make sure to add new product types.

liddl ninja
Jan 17, 2013
To get a hangover you need to stop drinking
Problem:

ROW 1 - text1
ROW 2 - text2

I want this information merged in a cell with the "-" as seperator like this:

text1-text2

How can I do this ?

Ragingsheep
Nov 7, 2009
Assuming cells are A1 and A2: =A1&"-"&A2.

liddl ninja
Jan 17, 2013
To get a hangover you need to stop drinking

Ragingsheep posted:

Assuming cells are A1 and A2: =A1&"-"&A2.

Thanks! I failed to mention that I have ton of cells that needs to be separated like this . Is there a way to not have to add every single cell ? (Pardon my poo poo explanation)

I figured it out.

liddl ninja fucked around with this message at 11:36 on May 7, 2014

Xenoborg
Mar 10, 2007

Until the last month or so, when I wanted a new line inside a cell alt+enter would do it. Now that no longer works for some reason. Anyone know of why this would be, or another way to insert a linebreak? Copying from another cell with a linebreak and re-writing the data is getting old.

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!

Xenoborg posted:

Until the last month or so, when I wanted a new line inside a cell alt+enter would do it. Now that no longer works for some reason. Anyone know of why this would be, or another way to insert a linebreak? Copying from another cell with a linebreak and re-writing the data is getting old.

Not sure why that happened, but this will work.

="Line 1"&char(10)&"Line 2"

Iunnrais
Jul 25, 2007

It's gaelic.
I've got a tricky Excel problem that might or might not have a solution.

I'm copying in a long list of blocks of cells from an HTML table that our database program outputs. I want to sort the BLOCKS of cells by the contents of the 2nd half of one of the cells in each block-- that is, the cell has "NAME (INITIALS)" and I need to sort by the "(INITIALS)" portion only (and then use a secondary sort on a different cell's contents).

I have no idea how one goes about causing an entire block of cells, 9 rows deep, to be sorted like this. Is there a way?

Xenoborg
Mar 10, 2007

I have 2 columns of data, column A has items and column B has quantities. There are many many duplicates. I want a function to sum all of the quantities of each item, IE the find total number of "item1". Using =SUMIF(A3:A200,"Item1",B3:B200)I get close, but it only counts how many times item1 appears in column A.

Professor Moriarty
May 16, 2007
strong vs. Earth attacks
2 problems that I'm trying to determine whether they can be solved via Excel:

1) Take a list of 6 random numbers. Divide them as evenly as possible while keeping the contents whole. For instance:
code:
A     12
B     16
C     8
D     6
E     7
F     11
The sum is 60, and split between 2 people would be 30, but I want Excel to output somehow that person 1 gets AB and person 2 gets CDEF. Even better if I can change the divisor to be more than 2 people.

2) Take a numbered list, make it a dropdown list in a cell, then have it call back to one of many lists similar to issue 1).

I've spent 4 hours trying to even determine whether this can be done without macros or not, and I'd settle for "Yes, this can be done" or "no, it can't be done with/without macros" at this point.

Professor Moriarty fucked around with this message at 00:33 on May 25, 2014

Ragingsheep
Nov 7, 2009
Should be a simple match problem:

I have the following table and I want to give a certain number and have excel match it with the closest number that is larger that my specified number and then return the value in the second column.

code:
A   B
3   2014
7   2015
10  2016
e.g. 1 should return 2014, 5 and 7 should return 2015.


edit: got it.

Ragingsheep fucked around with this message at 01:21 on May 27, 2014

FAN OF NICKELBACK
Apr 9, 2002
There are a bunch of full on paragraphs of data in a spreadsheet I work with. Control F works OK, but since this keeps getting added to/edited I decided to build a userform as a search engine.

I know I can create an array for the "tempstring = replace" bits, but it's not my primary concern right now. I also like seeing everything at a glance since I'm not done adding/editing that portion.

Since I have little to no search engine programming experience I'm wondering if anyone has any other suggestions for the below code. It does a pretty good job, but I'd really like to just generally make it as solid as possible (and hopefully pick up some new tactics along the way).

Think of the raw data as three columns: "Project Name," "Project Details" and "Project Updates"

Any suggestions?

code:
Private Sub CommandButton1_Click()
Dim lrow As Integer
Dim i As Integer
Dim T As Integer
Dim x As Long, Z As Long
Dim MatchCount As Integer
Dim TWB As Workbook
Dim TS As String
Dim compstring
Dim TempString As String
Dim internalcount As Integer
Dim BestMatch As Integer
Dim BestMatchAddy As String
Dim Tstring()
Dim Rstring()
Dim CompArray, Y
Me.TextBox1.SetFocus
DisplayResult = 0
BestMatch = 0
internalcount = 0
Set TWB = ThisWorkbook
TS = "Raw Data Records"
lrow = ThisWorkbook.Sheets(TS).UsedRange.Rows.Count + 1

'Make sure textbox isn't submitted with no text
If Me.TextBox1.Text = "" Then
    Searching.TextBox1.SetFocus
    MsgBox "Please enter at least one keyword!"

    Exit Sub
End If

'Take all the textbox text and separate all the words into a new string
Me.TextBox1.Text = " " & Me.TextBox1.Text & " "
 For i = 1 To Len(Searching.TextBox1.Text)
        Select Case Asc(Mid(Searching.TextBox1.Text, i, 1))
            Case 32, 48 To 57, 65 To 90, 97 To 122:
                TempString = TempString & Mid(Searching.TextBox1.Text, i, 1)
        End Select
    Next
    
'Remove words that would not help find specific data, and make sure finds aren't missed due to common contractions
    TempString = Replace(LCase(TempString), LCase(" is not "), " isnt ")
    TempString = Replace(LCase(TempString), LCase(" is "), " ")
    TempString = Replace(LCase(TempString), LCase(" about "), " ")
    TempString = Replace(LCase(TempString), LCase(" the "), " ")
    TempString = Replace(LCase(TempString), LCase(" their "), " ")
    TempString = Replace(LCase(TempString), LCase(" a "), " ")
    TempString = Replace(LCase(TempString), LCase(" was "), " ")
    TempString = Replace(LCase(TempString), LCase(" who "), " ")
    TempString = Replace(LCase(TempString), LCase(" they "), " ")
    TempString = Replace(LCase(TempString), LCase(" want "), " ")
    TempString = Replace(LCase(TempString), LCase(" were "), " ")
    TempString = Replace(LCase(TempString), LCase(" will "), " ")
    TempString = Replace(LCase(TempString), LCase(" be "), " ")
    TempString = Replace(LCase(TempString), LCase(" need "), " ")
    TempString = Replace(LCase(TempString), LCase(" for "), " ")
    TempString = Replace(LCase(TempString), LCase(" cannot "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" unable "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" isnt able to "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" can not "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" did not "), " wont ")
    TempString = Replace(LCase(TempString), LCase(" will not "), " dont ")
    TempString = Replace(LCase(TempString), LCase(" not "), " cant ")
    
Me.TextBox1.Text = " " & Me.TextBox1.Text & " "

'Clean up extra spaces and catch searches made of only words that we removed a minute ago
spacebits = Len(TempString)
 For i = 1 To Len(TempString)
        Select Case Asc(Mid(TempString, i, 1))
            Case 32:
                Me.TextBox1.Text = Trim(Me.TextBox1.Text)
                spacebits = spacebits - 1
            Case Else:
                Exit For
        End Select
        If spacebits = 0 Then
            Searching.TextBox1.SetFocus
            MsgBox "No results found (either the search terms were too vague, or there is no matching category)!"
                Me.TextBox1.Text = Trim(Me.TextBox1.Text)
            Exit Sub
        End If
    Next
    
'Split our new string of viable search terms into a proper array and get rid of duplicates
tsplit = Split(LCase(TempString), " ")
Y = 0
For Each CompArray In tsplit
    If UBound(Filter(tsplit, CompArray)) = 0 Then
        ReDim Preserve Tstring(Y)
        Tstring(Y) = CompArray
        Y = Y + 1
    Else
        On Error Resume Next
            tsplit(Application.Match(CompArray, tsplit, False) - 1) = ""
        On Error GoTo 0
     End If
Next
    Me.TextBox1.Text = Trim(Me.TextBox1.Text)
TempString = ""

'Combine each row of raw data, and do all the same things as we did to the textbox so we have two arrays of terms to compare and match
For T = 3 To lrow + 1
    TempString = ""
    rdata = ""
        rdata = LCase(" " & rdata & " " & TWB.Sheets(TS).Cells(T, 4).Value & " " & TWB.Sheets(TS).Cells(T, 3).Value & " " & TWB.Sheets(TS).Cells(T, 2).Value) & " "

        If InStr(rdata, "definition:") <> 0 Then
        Else
        For i = 1 To Len(rdata)
        Select Case Asc(Mid(rdata, i, 1))
            Case 32, 48 To 57, 65 To 90, 97 To 122:
                TempString = TempString & Mid(rdata, i, 1)
            Case Else
                TempString = TempString & " "
        End Select
          Next
    TempString = Replace(LCase(TempString), LCase(" is not "), " isnt ")
    TempString = Replace(LCase(TempString), LCase(" is "), " ")
    TempString = Replace(LCase(TempString), LCase(" about "), " ")
    TempString = Replace(LCase(TempString), LCase(" the "), " ")
    TempString = Replace(LCase(TempString), LCase(" their "), " ")
    TempString = Replace(LCase(TempString), LCase(" a "), " ")
    TempString = Replace(LCase(TempString), LCase(" was "), " ")
    TempString = Replace(LCase(TempString), LCase(" who "), " ")
    TempString = Replace(LCase(TempString), LCase(" they "), " ")
    TempString = Replace(LCase(TempString), LCase(" want "), " ")
    TempString = Replace(LCase(TempString), LCase(" were "), " ")
    TempString = Replace(LCase(TempString), LCase(" will "), " ")
    TempString = Replace(LCase(TempString), LCase(" be "), " ")
    TempString = Replace(LCase(TempString), LCase(" need "), " ")
    TempString = Replace(LCase(TempString), LCase(" for "), " ")
    TempString = Replace(LCase(TempString), LCase(" cannot "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" unable "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" isnt able to "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" can not "), " cant ")
    TempString = Replace(LCase(TempString), LCase(" did not "), " wont ")
    TempString = Replace(LCase(TempString), LCase(" will not "), " dont ")
    TempString = Replace(LCase(TempString), LCase(" not "), " cant ")
    
    rdata = TempString
    rsplit = Split(rdata, " ")


Y = 0
For Each CompArray In rsplit
        ReDim Preserve Rstring(Y)
        Rstring(Y) = CompArray
        Y = Y + 1
Next

'Compare our two arrays and count matches or "hits" for keywords in the row data

MatchCount = 0
  For x = 1 To UBound(Rstring)
    For Z = 0 To UBound(Tstring)
        If Rstring(x) Like "*" & Tstring(Z) & "*" Then
        MatchCount = MatchCount + 1
        internalcount = internalcount + 1
      End If
        If Rstring(x) = Tstring(Z) Then
        MatchCount = MatchCount + 1
        internalcount = internalcount + 1
      End If
    Next Z
  Next x
  
'Save the location of successful search results
  If MatchCount > BestMatch Then
    BestMatch = MatchCount
    BestMatchAddy = BestMatchAddy & " " & TWB.Sheets(TS).Cells(T, 4).Address
  End If
  MatchCount = 0
  
End If
    Next T

'Split all the addresses of our search results (so later I can give more than the best result, but right now it isn't necessary)
 bmatch = Split(BestMatchAddy, " ")
 
'If nothing met our terms then let us know
 If internalcount = 0 Then
 TextBox1.Text = ""
 Me.Label1.Caption = ""
 Me.Label2.Caption = ""
 Me.Label3.Caption = ""
 Searching.TextBox1.SetFocus
 MsgBox "No results found (either the search terms were too vague, or there is no matching category)!"
 Else

'Whichever result showed as strongest will have each column's data for the best row displayed in the userform
curbmatch = UBound(bmatch)
 Me.Label1.Caption = TWB.Sheets(TS).Range(bmatch(UBound(bmatch))).Offset(0, -2).Value
 Me.Label2.Caption = TWB.Sheets(TS).Range(bmatch(UBound(bmatch))).Offset(0, -1).Value
 Me.Label3.Caption = TWB.Sheets(TS).Range(bmatch(UBound(bmatch))).Value
 End If
     Searching.TextBox1.SetFocus
End Sub

FieryBalrog
Apr 7, 2010
Grimey Drawer
Given a mean and a standard devation, is there an easy way to generate a normal distribution graph in Excel?

The only way I did it is the following pants-on-head retarded technique:
1) use the mean and standard deviation to generate a fake distribution of data across the cells
2) use the fake data to generate the graph

There HAS to be a less rear end-backwards way, but an hour of googling could not uncover it for me.

Old James
Nov 20, 2003

Wait a sec. I don't know an Old James!


I didn't completely follow everything you were trying to do. But have you considered using the .Find method in your code? It is the CTRL+F function. You can use that with your search terms and loop through to get the list of cells that contain the words and from that then modify those cells as you see fit.

http://msdn.microsoft.com/en-us/library/office/ff839746(v=office.15).aspx

FAN OF NICKELBACK
Apr 9, 2002

FieryBalrog posted:

Given a mean and a standard devation, is there an easy way to generate a normal distribution graph in Excel?

The only way I did it is the following pants-on-head retarded technique:
1) use the mean and standard deviation to generate a fake distribution of data across the cells
2) use the fake data to generate the graph

There HAS to be a less rear end-backwards way, but an hour of googling could not uncover it for me.


This is basically what I do: http://exceluser.com/excel_dashboards/normalcurve.htm



I'm not sure how to do what I currently have with .find without a "do while" and creating error trapping. I try to avoid all that because I always end up creating more points of failure (I'm more determined than capable :/ ). If you've got a good direction for me to go with though, let me know. If I can figure that out it would probably be faster than looping as much as I am.

Also, sometimes I still get wonky matches due to a word or two being repeated a lot in the notes in a less relevant topic -- though I usually only have to try once or twice to find the right match (even if I didn't know that's what I was looking for).

Here's what the code currently does for reference:

-Gets rid of duplicate user-entered keywords, punctuation, superfluous spacing and standardizes common contractions so that if a paragraph has "Can't" and you use "Can not" in your keywords it will still recognize the match.

-Retains the cell address of best matches (adding each time it finds a better one) in order of worst to best, so that if I want to create a button to flip through all the matches in a meaningful order, I can.

Knot My President!
Jan 10, 2005

How would I go about averaging together column values based on another column's values?

code:
ID   Price  Average Price by ID (what I want to find)
1    50     50
2    25     50
2    75     50
3    10     10
4    10     15
4    20     15

Darth TNT
Sep 20, 2013

Armchair Calvinist posted:

How would I go about averaging together column values based on another column's values?

code:
ID   Price  Average Price by ID (what I want to find)
1    50     50
2    25     50
2    75     50
3    10     10
4    10     15
4    20     15

averageif or averageifs should work fine.

Knot My President!
Jan 10, 2005

Darth TNT posted:

averageif or averageifs should work fine.

Thanks! Just confirming that I'm not crazy, haha.

Zaffy
Sep 15, 2003


I get a report every week that looks like this:
code:
STUDENT NAME	Student ID	COURSE NAME		SCORE	PERCENT COMPLETE
Sarah		1		Language Arts 10A 	84.60%	100.00%
Sarah		1		Algebra 2A 		0.00%	0.00%
Sarah		1		Algebra 2B 		30.77%	56.67%
Sophia		2		Physical Education B	84.62%	100.00%
Mark		3		Physical Education A	79.27%	100.00%
Mark		3		Physical Education B	89.78%	100.00%
Justin		4		American History A 	88.04%	100.00%
Justin		4		Language Arts 12A 	67.56%	100.00%
Justin		4		Algebra 2A 		63.49%	100.00%
Justin		4		Geometry A 		60.46%	100.00%
Justin		4		Algebra 2B 		50.36%	96.67%
Carmen		5		Algebra 2A 		65.10%	100.00%
Carmen		5		World History A 	72.80%	100.00%
Herbert		6		Language Arts 12A 	28.73%	89.47%
Herbert		6		Language Arts 12B 	82.46%	100.00%
Herbert		6		Language Arts 11A 	55.30%	100.00%
I've removed about 10 columns for easy reading.

Is it possible to have excel move the data for each student into a single row, rather than having them in a row per class?

DukAmok
Sep 21, 2006

Using drugs will kill. So be for real.

Zaffy posted:

I get a report every week that looks like this:
code:
STUDENT NAME	Student ID	COURSE NAME		SCORE	PERCENT COMPLETE
Sarah		1		Language Arts 10A 	84.60%	100.00%
Sarah		1		Algebra 2A 		0.00%	0.00%
Sarah		1		Algebra 2B 		30.77%	56.67%
Sophia		2		Physical Education B	84.62%	100.00%
Mark		3		Physical Education A	79.27%	100.00%
Mark		3		Physical Education B	89.78%	100.00%
Justin		4		American History A 	88.04%	100.00%
Justin		4		Language Arts 12A 	67.56%	100.00%
Justin		4		Algebra 2A 		63.49%	100.00%
Justin		4		Geometry A 		60.46%	100.00%
Justin		4		Algebra 2B 		50.36%	96.67%
Carmen		5		Algebra 2A 		65.10%	100.00%
Carmen		5		World History A 	72.80%	100.00%
Herbert		6		Language Arts 12A 	28.73%	89.47%
Herbert		6		Language Arts 12B 	82.46%	100.00%
Herbert		6		Language Arts 11A 	55.30%	100.00%
I've removed about 10 columns for easy reading.

Is it possible to have excel move the data for each student into a single row, rather than having them in a row per class?

What do you want in that single row? A pivot table can definitely consolidate that, or it's possible to build some simple sumifs in another sheet to summarize the data for you.

Knot My President!
Jan 10, 2005

Another question!

How would I go about doing this?

code:
ID   Price  Average Price by ID
1    50     50
2    25     50
2    75     50
3    10     10
4    10     15
4    20     15
            31.25 (average of each unique ID's average price) / (count total of unique IDs) --> (50 + 50 + 10 + 15) / 4

Darth TNT
Sep 20, 2013

Armchair Calvinist posted:

Another question!

How would I go about doing this?

code:
ID   Price  Average Price by ID
1    50     50
2    25     50
2    75     50
3    10     10
4    10     15
4    20     15
            31.25 (average of each unique ID's average price) / (count total of unique IDs) --> (50 + 50 + 10 + 15) / 4

As far as I know there is no formula to count the number of unique entries. The ways I do these things is to either use a pivot table to get the number of unique ideas by putting them in a list or using another column and using a formula like if(A2=A1;0;1) and then summing up that column. Of course the second version only works if it has been properly sorted in an ascending fashion!

Ragingsheep
Nov 7, 2009

Armchair Calvinist posted:

Another question!

How would I go about doing this?

code:
ID   Price  Average Price by ID
1    50     50
2    25     50
2    75     50
3    10     10
4    10     15
4    20     15
            31.25 (average of each unique ID's average price) / (count total of unique IDs) --> (50 + 50 + 10 + 15) / 4

This is easy to do if you split it out.

Assuming that the "ID" is in cell A1: in D2 enter the formula '=1/COUNTIFS($A$2:$A$7,A2)' and drag down. Then in cell D8 '=SUMPRODUCT($C$2:$C$7,D2:D7)/SUM(D2:D7)'

me your dad
Jul 25, 2006

I've got a file containing the following type of data. Each element exists in its own cell. I'm trying to extract the first name, last name, suffix, and email address.

code:
FirstName LastName Suffix
CompanyName
Division
Street1
Street2
City, State, Zip
Phone: (123) 456-7890
[email]email@domain.com[/email]




FirstName LastName Suffix
CompanyName
Division
Street1
Street2
City, State, Zip
Phone: (123) 456-7890
[email]email@domain.com[/email]

FirstName LastName
CompanyName
Street1
City, State, Zip
Phone: (123) 456-7890
[email]email@domain.com[/email]




FirstName LastName Suffix
CompanyName
Street1
City, State, Zip
[email]email@domain.com[/email]
It's tough to see here, but some of the blocks are separated by two empty rows, and some are separated by one empty row. This is the first hurdle. The second hurdle is that the number of rows containing the data isn't uniform. Some blocks have five rows, some have eight, some have seven. It depends on the length of their mailing address.

But, the name of the person is always the first line of each block.

I'm thinking it may be best easiest possible to:

Create a macro to go row by row, extracting data from the first populated cell after an empty cell. Each element (First Name, Last Name, Suffix, Email Address), should be copied into their own cells, row by row.

I'd then need to skip down until an email address is found, and extract that into the end of the same row containing the full name data.

Does that sound doable? Might there be a smarter way to go about it?

me your dad fucked around with this message at 17:01 on Jun 3, 2014

Adbot
ADBOT LOVES YOU

sofokles
Feb 7, 2004

Fuck this
if email is always last in the block i'd loop through twice

dim a couple of sheets ws1 and ws2
dim rows(1 to more than enough) as double
dim hits as double

first get all the interesting rownumbers in ws1

pre:
set ws = activesheet
hits = 0

for i in 1 to lastrow
   if cell(i,1).value <>"" then 
       if cell(i-1,1) = "" then 
           hits = hits + 1
           rows(hits) = i
       else if cell(i+1,1) = "" then 
           hits = hits + 1
           rows(hits) = i
       end if
    end if
next
next get all the values copied over from ws1 to ws2

pre:
set ws2 = activeworkbook.sheets.add



for i in 1 to hits
   if i-(2*(i\2)) = 1 then
      ws2.cell(i,1).value = ws1.cell(rows(i),1).value 
      ws2.cell(i,2).value = ws1.cell(rows(i),2).value
      ws2.cell(i,3).value = ws1.cell(rows(i),3).value
   else
      ws.cell(i-1,4).value = ws1.cell(rows(i),1).value
   end if
next
that'd give the info on every second row. just delete teh empty rows.

You need to have at least one empty row at the top of the original sheet for it to work.

Edit - mod operator updated

sofokles fucked around with this message at 20:07 on Jun 3, 2014

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply