PDA

View Full Version : Solved: Calling Subs::Error "Compile Error: Expected Variable or Procedure, Not Module"



Saladsamurai
09-03-2009, 08:39 AM
Okay then! The problem is: I really don't know what I am doing:think:


I am trying to break up one really long Sub into Modules, and then just call them.

The user should click on a Button in the Spreadsheet:

Private Sub CommandButton1_Click()
Call Main
End Sub


Which Calls "Main" module: (I think this is where the error comes up)

Public MyError_T As Double
Public Percent As Double
Public CI_WithinTen As Double
Public MyMax_CI As Double
Public MyMax_T As Double
Public ErrorSquare_CI As Double
Public ErrorSquare_T As Double
Public BestCI_CFD As Worksheet
Public BestCI_ISX As Worksheet
Public DataAnalysis As Worksheet
Public T_CFD As Worksheet
Public T_ISX As Worksheet
Public End_Error_CI_R As Long
Public End_CI_R_Within5 As Long
Public End_CI_R_Within5_10 As Long
Public End_CI_R_Within10_20 As Long
Public End_CI_R_Within20_30 As Long
Public End_CI_R_Within30_40 As Long
Public End_CI_R_Within40_50 As Long
Public End_CI_R_Over50 As Long
Public End_Error_CI_L As Long
Public End_CI_L_Within5 As Long
Public End_CI_L_Within5_10 As Long
Public End_CI_L_Within10_20 As Long
Public End_CI_L_Within20_30 As Long
Public End_CI_L_Within30_40 As Long
Public End_CI_L_Within40_50 As Long
Public End_CI_L_Over50 As Long



Sub Main()
Call Initialize
Call CI
Call Temperature
End Sub


Calling Initialize:
Sub Initialize()


Set BestCI_CFD = Worksheets("Best CI CFD")
Set BestCI_ISX = Worksheets("Best CI ISX")
Set T_CFD = Worksheets("Temp CFD")
Set T_ISX = Worksheets("Temp ISX")
Set DataAnalysis = Worksheets("Data Analysis")


nRow = 25
nCol = 50
xgg = 0
xgy = 0
xgr = 0
xyg = 0
xyy = 0
xyr = 0
xrg = 0
xry = 0
xrr = 0
G = 0
Y = 0
R = 0
MyMax_CI = 0
Percent = 0
OverPredicted = 0
CI_WithinTen = 0
ErrorSquare_CI = 0
ErrorSquare_T = 0

Within5 = 0
Within5_10 = 0
Over10 = 0
Counter = 0

End_CI_R_Within5 = 0
End_CI_R_Within5_10 = 0
End_CI_R_Within10_20 = 0
End_CI_R_Within20_30 = 0
End_CI_R_Within30_40 = 0
End_CI_R_Within40_50 = 0
End_CI_R_Over50 = 0
End_CI_L_Within5 = 0
End_CI_L_Within5_10 = 0
End_CI_L_Within10_20 = 0
End_CI_L_Within20_30 = 0
End_CI_L_Within30_40 = 0
End_CI_L_Within40_50 = 0
End_CI_L_Over50 = 0
End Sub


and so on...

Saladsamurai
09-03-2009, 08:53 AM
Got it!

Can't have the modules that contain the Subs be named the same as the Subs themselves....

mdmackillop
09-03-2009, 08:53 AM
You call the Sub, not the module. If you have two identically named subs in different modules, you prefix with the module name so

Call Initialize
'or
Call Main!Initialize