Hi, I have the simplest question, but I just can't do it!!!!
Excel sheet:
Name (column heading)
James
Greg
Greg
(etc.)
Thats it! Now, I just want a graph (pie, or whatever) broken up by name!
So the example above would have a pie chart with 2/3 Greg and 1/3 James!!
(My excel sheet has more, but you get the idea)...
Why can't I do this?!?!
Name Total
James 1
Greg 2
Charting options, data Labels : Percentage
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
I preferably want to do this on the fly, and not create another sheet with totals.
The reason for this is that this document will be used on an ongoing basis, with new names being added, as well as additions of existing names. So it would be a hassle to add a new name to the totals sheet and then reprogram the chart each time this occurs...
So, without a totals column/sheet, can we do this on the fly?
For each...
Count unique...
??
Thanks!
Name
Greg
Greg
Juke
Juke
Ron
Ron
Ron
Select the Column, Data, Subtotals. Each change in Name, Use function Count. Result:
Name
Greg Count 2
Juke Count 2
Ron Count 3
Select and do what I have described before
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
This looks again like another total-ing option.
Surely there must be a way I can define the data set to include a function which does this?
brad, I see why this is killing you. Maybe blink twice and the chart will appear by itself
- A small macro could do the trick. A single button in the worksheet to press.
All possible, but ...
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Here some code for you. can you do the rest yourself? If not I will help you further...
Sub Find1() Dim Rng As Range, Ccell As Range Dim ResultArray() As Variant 'Nx2 array with names and totals Dim NameCounter As Long, Counter As Long Dim Found As Boolean NameCounter = 1 Set Rng = Range(Range("A1"), Range("A65536").End(xlUp)) 'to select [A1] to the last cell ReDim ResultArray(1 To Rng.Cells.Count, 1 To 2) For Each Ccell In Rng Found = False For Counter = 1 To NameCounter If Ccell = ResultArray(Counter, 1) Then ResultArray(Counter, 2) = ResultArray(Counter, 2) + 1 Found = True Exit For 'No Need to continue End If Next Counter If Not Found Then NameCounter = NameCounter + 1 ResultArray(NameCounter, 1) = Ccell ResultArray(NameCounter, 2) = 1 End If Next End Sub
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Thanks, im not sure how to implement that... but on the same token im not keen to implement a macro at all... Also, as your solution counts all of the cells up to 65K, it will be slow with multiple instances of that macro...
Also, im looking at implementing the solution on a much bigger scale, more than just 1 column - the idea of my question is just to find out how excel can count instances of a string and then compile those into a graph!
Surely, surely we're missing a very simple solution to this! The problem is not difficult!!!!
Thanks!!!!
Is not quit true, but anyway...Also, as your solution counts all of the cells up to 65K, it will be slow with multiple instances of that macro...
The only thing I can think of when implementing:
You should consider Pivot Tables. This has the Count function in it. In case of this example drag Name in the "Row fields" and in the "Data Items"a solution on a much bigger scale, more than just 1 column
If this did not gave you the solution, I hope someone smarter than me will give it a go.
Last edited by rwgrietveld; 09-13-2008 at 04:56 AM. Reason: small correction
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
As rwgrietveld points out the only auto solution is pivot table/graph.
Graphs do not summarize your data they only present it and it has to be numeric.
You need to calculate the totals before charting. You can use formula, subtotals or code but the crucial thing is you need to do it as the chart will not.
The pivot chart did it!!! I've never really gotten into pivot chart, but your description of how to utilise it sis the trick!!
My only question is how to refresh the pivot chart's data... I know you can right click 'refresh'.... but is there a way i can make a button to put on the sheet which can refresh the data?
Thanks for your help!
brad.tho,
Please be sure to read the Forum Rules about thread titles before starting your next thread.
This is unusual exept when it is part of total macro as this button already exists (the exclamation mark
Anyway:
Private Sub CommandButton1_Click() Worksheets("Sheet2").PivotTables("PivotTable1").PivotCache.Refresh End Sub
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks