Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,560
Default Making a chart from Row of numbers

I have a worksheet that has 3 columns and numerous rows with the numbers 1
through 10. Each row has different numbers and I am looking to make a chart
that shows which numbers are in the row together. Any suggestions?

example

Row1 Row2 Row3
1 2 3
4 1 6
2 7 9

Chart:
NUM 1 2 3 4 5 6... etc
1 2 1 1 1 0 1
2 1 2 1 0 0 0
...etc.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 87
Default Making a chart from Row of numbers

Here are a couple suggestions. (One concern with both would be if and
how you would treat a row that had the same number on it twice, ie. 1,
1, 4 or something like that)

I'm assuming that you have the #'s 1 to 10 in cells F3:F12 and in
G2:P2. Put the following formula in G3 and copy down across (This
formula counts duplicates twice, ie. 1,1,3 would produce 3 matches for
1)
=SUMPRODUCT(($A$2:$A$360=$F3)+($B$2:$B$360=$F3)+($ C$2:$C$360=$F3),($A$2:$A$360=G$2)+($B$2:$B$360=G$2 )+($C$2:$C$360=G$2))

If you only want 1,1,3 to produce 1 match for the value 1, you could
use the following formula:
=IF($F3=G$2,COUNTIF($A$2:$C$360,$F3),SUMPRODUCT(($ A$2:$A$360=$F3)+($B$2:$B$360=$F3)+($C$2:$C$360=$F3 ),($A$2:$A$360=G$2)+($B$2:$B$360=G$2)+($C$2:$C$360 =G$2)))

Alternatively, you can use a macro like the following:

Option Explicit

Const SOURCESHEET As String = "Sheet1"
Const DEST As String = "$F$2" 'Same sheet
Const STARTCOL As Long = 1 'First column of data
Const STARTROW As Long = 2 'First row of data

Public Sub Generate()
Dim WS As Worksheet
Dim SrcData As Variant
Dim LastRow As Long
Dim Count(1 To 10, 1 To 10) As Long
Dim i As Long, j As Long
Dim x As Long, y As Long, z As Long

Set WS = Worksheets(SOURCESHEET)
LastRow = WS.Cells(65536, STARTCOL).End(xlUp).Row
SrcData = WS.Range(WS.Cells(STARTROW, STARTCOL), WS.Cells(LastRow,
STARTCOL + 2)).Value

For i = 1 To (LastRow - STARTROW + 1)
x = SrcData(i, 1)
y = SrcData(i, 2)
z = SrcData(i, 3)
Count(x, x) = Count(x, x) + 1
Count(y, y) = Count(y, y) + 1
Count(z, z) = Count(z, z) + 1
Count(y, x) = Count(y, x) + 1
Count(x, y) = Count(y, x)
Count(z, x) = Count(z, x) + 1
Count(x, z) = Count(z, x)
Count(y, z) = Count(y, z) + 1
Count(z, y) = Count(y, z)

Next i

For i = 1 To 10
For j = 1 To 10
WS.Range(DEST).Offset(i, j) = Count(i, j)
Next j
Next i
End Sub

Scott

David wrote:
I have a worksheet that has 3 columns and numerous rows with the numbers 1
through 10. Each row has different numbers and I am looking to make a chart
that shows which numbers are in the row together. Any suggestions?

example

Row1 Row2 Row3
1 2 3
4 1 6
2 7 9

Chart:
NUM 1 2 3 4 5 6... etc
1 2 1 1 1 0 1
2 1 2 1 0 0 0
..etc.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 87
Default Making a chart from Row of numbers

Here are a couple suggestions. (One concern with both would be if and
how you would treat a row that had the same number on it twice, ie. 1,
1, 4 or something like that)

I'm assuming that you have the #'s 1 to 10 in cells F3:F12 and in
G2:P2. Put the following formula in G3 and copy down across (This
formula counts duplicates twice, ie. 1,1,3 would produce 3 matches for
1)
=SUMPRODUCT(($A$2:$A$360=$F3)+($B$2:$B$360=$F3)+($ C$2:$C$360=$F3),($A$2:$A$360=G$2)+($B$2:$B$360=G$2 )+($C$2:$C$360=G$2))

If you only want 1,1,3 to produce 1 match for the value 1, you could
use the following formula:
=IF($F3=G$2,COUNTIF($A$2:$C$360,$F3),SUMPRODUCT(($ A$2:$A$360=$F3)+($B$2:$B$360=$F3)+($C$2:$C$360=$F3 ),($A$2:$A$360=G$2)+($B$2:$B$360=G$2)+($C$2:$C$360 =G$2)))

Alternatively, you can use a macro like the following:

Option Explicit

Const SOURCESHEET As String = "Sheet1"
Const DEST As String = "$F$2" 'Same sheet
Const STARTCOL As Long = 1 'First column of data
Const STARTROW As Long = 2 'First row of data

Public Sub Generate()
Dim WS As Worksheet
Dim SrcData As Variant
Dim LastRow As Long
Dim Count(1 To 10, 1 To 10) As Long
Dim i As Long, j As Long
Dim x As Long, y As Long, z As Long

Set WS = Worksheets(SOURCESHEET)
LastRow = WS.Cells(65536, STARTCOL).End(xlUp).Row
SrcData = WS.Range(WS.Cells(STARTROW, STARTCOL), WS.Cells(LastRow,
STARTCOL + 2)).Value

For i = 1 To (LastRow - STARTROW + 1)
x = SrcData(i, 1)
y = SrcData(i, 2)
z = SrcData(i, 3)
Count(x, x) = Count(x, x) + 1
Count(y, y) = Count(y, y) + 1
Count(z, z) = Count(z, z) + 1
Count(y, x) = Count(y, x) + 1
Count(x, y) = Count(y, x)
Count(z, x) = Count(z, x) + 1
Count(x, z) = Count(z, x)
Count(y, z) = Count(y, z) + 1
Count(z, y) = Count(y, z)

Next i

For i = 1 To 10
For j = 1 To 10
WS.Range(DEST).Offset(i, j) = Count(i, j)
Next j
Next i
End Sub

Scott

David wrote:
I have a worksheet that has 3 columns and numerous rows with the numbers 1
through 10. Each row has different numbers and I am looking to make a chart
that shows which numbers are in the row together. Any suggestions?

example

Row1 Row2 Row3
1 2 3
4 1 6
2 7 9

Chart:
NUM 1 2 3 4 5 6... etc
1 2 1 1 1 0 1
2 1 2 1 0 0 0
..etc.


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
Creating a chart with text not numbers aj1152 Charts and Charting in Excel 1 November 10th 06 09:04 PM
Making a chart that uses a secondary Y axis NightWalker Charts and Charting in Excel 1 October 10th 06 08:37 AM
Making chart with hidden Data dandigger Excel Discussion (Misc queries) 2 September 16th 06 07:55 PM
Sorting values in a bar chart Eric D Charts and Charting in Excel 4 April 17th 06 04:44 PM
Numbers instead of symbols on scatter chart Bill Sturdevant Charts and Charting in Excel 2 June 27th 05 07:20 PM


All times are GMT +1. The time now is 06:37 AM.

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

About Us

"It's about Microsoft Excel"