Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
passing values to other sheets | New Users to Excel | |||
Passing values in Sheet to VBA | Charts and Charting in Excel | |||
Passing selected workbook name and values to a macro | Excel Worksheet Functions | |||
passing values from one sheet to another | Excel Programming | |||
Userform and passing date values | Excel Programming |