PC Review


Reply
Thread Tools Rate Thread

Data analysis by 2-dimensional data table + database

 
 
H.G. Lamy
Guest
Posts: n/a
 
      17th Nov 2009
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



 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      17th Nov 2009
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
H.G. Lamy
Guest
Posts: n/a
 
      17th Nov 2009
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
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BIDS - Excel Pivot Table - Data Cube - What - if analysis Milton Microsoft Excel Programming 0 5th Aug 2009 10:30 AM
Analysis Toolpak-Confidence Level and data analysis questions MH Microsoft Excel Worksheet Functions 0 3rd Jan 2009 06:15 PM
What-If Analysis w Data Table and Input on Different Sheet =?Utf-8?B?TllLYXJs?= Microsoft Excel Misc 2 8th Aug 2007 03:12 PM
input data in asp.net and analysis with pivot table Grey Microsoft ASP .NET 1 24th Sep 2004 02:23 PM
insert a data record into a data table of a access database(mdb) authorking Microsoft C# .NET 4 5th Aug 2004 11:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:53 PM.