View Single Post
  #15  
Old August 14th, 2007, 12:27 PM posted to microsoft.public.excel.misc
Zone[_3_]
external usenet poster
 
Posts: 127
Default how to analyze data?

Hi Linda,
This macro assumes that:
1. The original table begins in cell A1 of the first worksheet and has at
least one blank row after it and at least one blank column to the right of
it.
2. The workbook has a second worksheet available, and the new table will be
the only thing on the second worksheet.
If these assumptions are correct,
1. Open the workbook in Excel
2. Show the code editor by pressing Alt-F11
3. If the workbook doesn't have a regular code module, insert one by
clicking Insert on the menubar, then Module.
4. Copy the code below and paste it in the module.
5. Press Alt-F11 to return to the spreadsheet.
6. To run the macro, click Tools on the menubar, then Macro, then Macros,
and select CustModTable from the list, then Run.
Post back and let me know if the code works for you. If so, we'll add a
button to run it.
James

Sub CustModTable()
Dim FromRow As Long, FromCol As Integer, c As Range, c2 As Range
Dim ToRow As Long, ToCol As Integer, This As Variant, This2 As Variant
Worksheets(2).Activate
Cells.ClearContents
ToRow = 2: ToCol = 1: FromCol = 1
With Worksheets(1)
For FromRow = 1 To .Cells(1, "a").End(xlDown).Row
This = .Cells(FromRow, FromCol)
Set c = Cells.Find(This, LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
Cells(ToRow, ToCol) = This
ToRow = ToRow + 1
End If
Next FromRow
[a1] = "Cust"
ToRow = 1: ToCol = 2: FromCol = 2
For FromRow = 1 To .Cells(1, "b").End(xlDown).Row
This = .Cells(FromRow, FromCol)
Set c = Cells.Find(This, LookIn:=xlValues, lookat:=xlWhole)
If c Is Nothing Then
Cells(ToRow, ToCol) = This
ToCol = ToCol + 1
End If
Next FromRow
For ToRow = 2 To Cells(1, "a").End(xlDown).Row
For ToCol = 2 To Cells(1, 1).End(xlToRight).Column
Cells(ToRow, ToCol) = 0
Next ToCol
Next ToRow
For FromRow = 1 To .Cells(1, "b").End(xlDown).Row
This = .Cells(FromRow, "a")
This2 = .Cells(FromRow, "b")
Set c = Cells.Find(This, LookIn:=xlValues, lookat:=xlWhole)
Set c2 = Cells.Find(This2, LookIn:=xlValues, lookat:=xlWhole)
Cells(c.Row, c2.Column) = Cells(c.Row, c2.Column) + 1
Next FromRow
End With
End Sub


"linda" wrote in message
...
Hi James!

hope you can send me the code cause i need to do it in macro..using wizard
doesnt solve my problem.
your help is really appreciated.
--
Regards,
Linda


"Zone" wrote:

Linda, you have had some good replies. However, if you still want to do
this with a macro, post back and I'll post the code. James

"linda" wrote in message
...
hi!

i've got a table in excel worksheet which part of it looks like this:

columnA|column B|
cust1 | mod1
cust2 | mod2
cust1 | mod1
cust1 | mod2
cust2 | mod3
cust2 | mod3

but,i need to recreate the table in a new worksheet to be analyze,to
create
chart from the data..this is what i expect:

cust | mod1 | mod2 | mod3 |
cust1| 2 | 1 |
cust2| 0 | 1 | 2

i've try to use filter,but still can't do this..i dont want to create
it
using pivot table cause i want it to be static..i hope to do this in
macro
cause i want to assign it to a button but i'm not really familiar with
macro..so,i dont have any idea to solve my this.is there any solution
for
this?if yes,how?

thanks in advanced.
--
Regards,
Linda