LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Data analysis by 2-dimensional data table + database

Bernie,

thank you very much for your suggestion, I'll have a close look at it to see
if I can use it (I'm not yet very familiar with VBA).

The model I originally refered to, however, simply harnessed the command
"Data - table..." (English version) or "Daten - Mehrfachoperation..."
(German version), without any programming (VBA was unknown to early XL
anyway).

In case there is still an old manual (MS still printed them out at the time)
of Excel 3 around - the technique was shown/explained there on page 500 +
something. Any idea where to retrieve that ?

Thank you in advance.

Kind regards,

H.G. Lamy



"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
H.,

I think that you are talking about a cross-tab table.

There are two ways to convert a database to a cross-tab table.

If you have a three column database, and the third column is numeric,
simply use the database as the source of a pivot table. Drag column A to
the row field, column B to the column field, and column C to the data
field, set to sum.

Or you can use a macro, like the one below, which converts a three column
database to a cross-tab table.

HTH,
Bernie
MS Excel MVP


Sub DBtoCrossTab2()
Dim myCell As Range
Dim myTable As Range
Dim mySht As Worksheet
Dim myRow As Long
Dim myCol As Integer

Set myTable = ActiveCell.CurrentRegion

If myTable.Columns.Count < 3 Then
MsgBox "This macro works on a 3 column database only"
Exit Sub
End If

On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Cross Tab").Delete
Application.DisplayAlerts = True

Set mySht = Worksheets.Add
mySht.Name = "Cross Tab"

'myTable.Rows(1).EntireRow.Copy mySht.Rows(1)

Set myTable = myTable.Offset(1, 0).Resize _
(myTable.Rows.Count - 1, myTable.Columns.Count)
MsgBox myTable.Address
MsgBox myTable.Columns(1).Cells.Address

For Each myCell In myTable.Columns(1).Cells
If IsError(Application.Match(myCell.Value, _
mySht.Range("A:A"), False)) Then
mySht.Range("A65536").End(xlUp)(2).Value = myCell.Value
End If
If IsError(Application.Match(myCell(1, 2).Value, _
mySht.Range("1:1"), False)) Then
mySht.Range("IV1").End(xlToLeft)(1, 2).Value = myCell(1, 2).Value
End If
myRow = Application.Match(myCell.Value, _
mySht.Range("A:A"), False)
myCol = Application.Match(myCell(1, 2).Value, _
mySht.Range("1:1"), False)

If IsNumeric(myCell(1, 3).Value) Then
mySht.Cells(myRow, myCol).Value = mySht.Cells(myRow, myCol).Value +
myCell(1, 3).Value
Else
mySht.Cells(myRow, myCol).Value = myCell(1, 3).Value
End If
Next myCell

End Sub




"H.G. Lamy" wrote in message
...
Hello,

in an old Excel-manual (possibly way back to version 3) by Microsoft
there was an excellent example of a 2-dimensional datatable (in German:
Mehrfachoperation) with input variables based on database results. Now I
would need to apply this technique, but my old manual is lost, and I
can't figure out by heart exactly how this was done.

Does somebody still have an old manual from which to draw the model, or
can let me know the deatils of the trick?

Thank you in advance.

Kind regards,

H.G. Lamy







 
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
BIDS - Excel Pivot Table - Data Cube - What - if analysis Milton Excel Programming 0 August 5th 09 10:30 AM
Export 1-dimensional array values to a two-dimensional table? Laurie Excel Programming 2 November 8th 07 03:51 PM
What-If Analysis w Data Table and Input on Different Sheet NYKarl Excel Discussion (Misc queries) 2 August 8th 07 03:12 PM
can data be sent from a cell in excel to a database table? mtarkington Excel Programming 0 March 17th 06 03:57 PM
Why " data analysis plus " override " data analysis " once instal. Alfred H K Yip Excel Worksheet Functions 1 March 20th 05 08:10 AM


All times are GMT +1. The time now is 11:43 PM.

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"