Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Passing values between 2 subs ?

I am setting oAPP in SUB OPENFILE. How do I pass oAPP
to the SUB RunANOVA?
I am using
oAPP.ExecuteCommands sANOVA, True
in Sub RunANOVA but I keep getting
an error and I assume it is because
oAPP is not getting passed to
SubANOVA

Lance



Sub Openfile()
Dim Varlist As String

'OPEN DIALOG BOX TO OPEN SPSSFILE
OFile = Application.GetOpenFilename("SPSS Datafile, *.sav")

'USE OLE TO OPEN SPSS
Set oAPP = CreateObject("SPSS.Application")
Set oDoc = oAPP.OpenDataDoc(OFile)
'oDoc.Visible = True


'USE OLE TO OPEN OUTPUT DOC
Set oOut = oAPP.NewOutputDoc

'Switch back to Excel after SPSS opens
AppActivate "Microsoft Excel"

End Sub





Sub RunANOVA()


Worksheets("Vars").Select
Range("C2:C101").Select
'Find out how many variables there are in the ANOVA
myCount = Application.CountA(Selection)
'If over 100, then stop (SPSS can only input 100)
If (myCount 99) Then
MsgBox ("Wait a minute there buddy, SPSS only allows you to input up to
100 variables")
Sheets("Mainsheet").Select
End
End If



'Concantenate variables so that they are not an array

For RowIndex = 2 To (1 + myCount)
myVars4ANOVA = myVars4ANOVA & Cells(RowIndex, 3) & " "
'Add plus sign for Basic Tables
If (RowIndex < (1 + myCount)) Then
myVars4Table = myVars4Table & Cells(RowIndex, 3) & "+"
Else
myVars4Table = myVars4Table & Cells(RowIndex, 3)
End If
Next RowIndex
'Get grouping variable
Groupvar = Range("E2").Value


sANOVA = "ONEWAY " & myVars4ANOVA & " BY Groupvar /STATISTICS
DESCRIPTIVES HOMOGENEITY /MISSING ANALYSIS /POSTHOC = LSD ALPHA(.05)."
oAPP.ExecuteCommands sANOVA, True




sTables = "* Basic Tables. TEMPORARY. NUMERIC T0000000. LEAVE T0000000.
VARIABLE LABEL T0000000 'Table Total'. VALUE LABELS T0000000 0 ' '.
TABLES /FORMAT BLANK MISSING('.') /OBSERVATION" & myVars4ANOVA & "
/TABLES (" & myVars4Table & "BY (" & Groupvar & "+ T0000000)
(STATISTICS) /STATISTICS mean( ( F7.2 ))."
oAPP.ExecuteCommands sTables, True


oAPP.CloseDataDoc (OFile)
oOut.CloseOutputDoc (oOut)
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Passing values between 2 subs ?

Sub RunANOVA( oApp as Object, sANOVA as String)
oAPP.ExecuteCommand sANOVA
End Sub

Sub OPENFILE()

.. . .

runANOVA oAPP

End Sub

--
Regards,
Tom Ogilvy


wrote in message
...
I am setting oAPP in SUB OPENFILE. How do I pass oAPP
to the SUB RunANOVA?
I am using
oAPP.ExecuteCommands sANOVA, True
in Sub RunANOVA but I keep getting
an error and I assume it is because
oAPP is not getting passed to
SubANOVA

Lance



Sub Openfile()
Dim Varlist As String

'OPEN DIALOG BOX TO OPEN SPSSFILE
OFile = Application.GetOpenFilename("SPSS Datafile, *.sav")

'USE OLE TO OPEN SPSS
Set oAPP = CreateObject("SPSS.Application")
Set oDoc = oAPP.OpenDataDoc(OFile)
'oDoc.Visible = True


'USE OLE TO OPEN OUTPUT DOC
Set oOut = oAPP.NewOutputDoc

'Switch back to Excel after SPSS opens
AppActivate "Microsoft Excel"

End Sub





Sub RunANOVA()


Worksheets("Vars").Select
Range("C2:C101").Select
'Find out how many variables there are in the ANOVA
myCount = Application.CountA(Selection)
'If over 100, then stop (SPSS can only input 100)
If (myCount 99) Then
MsgBox ("Wait a minute there buddy, SPSS only allows you to input up to
100 variables")
Sheets("Mainsheet").Select
End
End If



'Concantenate variables so that they are not an array

For RowIndex = 2 To (1 + myCount)
myVars4ANOVA = myVars4ANOVA & Cells(RowIndex, 3) & " "
'Add plus sign for Basic Tables
If (RowIndex < (1 + myCount)) Then
myVars4Table = myVars4Table & Cells(RowIndex, 3) & "+"
Else
myVars4Table = myVars4Table & Cells(RowIndex, 3)
End If
Next RowIndex
'Get grouping variable
Groupvar = Range("E2").Value


sANOVA = "ONEWAY " & myVars4ANOVA & " BY Groupvar /STATISTICS
DESCRIPTIVES HOMOGENEITY /MISSING ANALYSIS /POSTHOC = LSD ALPHA(.05)."
oAPP.ExecuteCommands sANOVA, True




sTables = "* Basic Tables. TEMPORARY. NUMERIC T0000000. LEAVE T0000000.
VARIABLE LABEL T0000000 'Table Total'. VALUE LABELS T0000000 0 ' '.
TABLES /FORMAT BLANK MISSING('.') /OBSERVATION" & myVars4ANOVA & "
/TABLES (" & myVars4Table & "BY (" & Groupvar & "+ T0000000)
(STATISTICS) /STATISTICS mean( ( F7.2 ))."
oAPP.ExecuteCommands sTables, True


oAPP.CloseDataDoc (OFile)
oOut.CloseOutputDoc (oOut)
End Sub



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
passing values to other sheets [email protected] New Users to Excel 1 February 23rd 08 02:03 AM
Passing values in Sheet to VBA Jonathan Charts and Charting in Excel 1 June 30th 06 06:00 AM
Passing selected workbook name and values to a macro simora Excel Worksheet Functions 0 May 25th 05 07:24 PM
passing values from one sheet to another BubBob[_2_] Excel Programming 1 September 4th 03 01:09 PM
Userform and passing date values DTM Excel Programming 2 July 23rd 03 04:00 AM


All times are GMT +1. The time now is 03:54 PM.

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"