PDA

View Full Version : macro does not run



Pilot5000
08-12-2015, 08:07 AM
Hi guys

i have the following code that i converted from lotus123


Sub CLCDTL23()
'B1_4 2yr Avg Application.ScreenUpdating = False If Sheets("sheet A").Range("BH1301") = 1 Then Application.Run CLCDTL23N
If Range("G1207") <= Sheets("sheet D").Range("C3") Then Application.Run CLCDTL210
End If
End If
Application.ScreenUpdating = True
End Sub


my problem is that every time i try to run this code i get the message "Object doesn't support this property or method" any idea how to fix that ???
thank you in advance everyone

Kenneth Hobs
08-12-2015, 08:49 AM
I doubt that you need Application.Run. IF the called routine is in a Module:

If Range("G1207").Value <= Sheets("sheet D").Range("C3").Value Then CLCDTL210

Paul_Hossler
08-12-2015, 12:27 PM
Little hard to tell what the statements are.

As Ken said, you don't need .Run, but you were probably using it incorrectly



From online help for .Run
The macro to run. This can be either a string with the macro name,
a Range object indicating where the function is,
or a register ID for a registered DLL (XLL) function.
If a string is used, the string will be evaluated in the
context of the active sheet.




Also there looked like there were 2 End If's that were not needed since the 'Then' parameter was in the same statement. You could use different lines, like the second sample





Sub CLCDTL23()
'B1_4 2yr Avg
Application.ScreenUpdating = False

If Sheets("sheet A").Range("BH1301") = 1 Then CLCDTL23N
If Range("G1207") <= Sheets("sheet D").Range("C3") Then CLCDTL210

Application.ScreenUpdating = True
End Sub






Sub CLCDTL23_a()
Application.ScreenUpdating = False
If Sheets("sheet A").Range("BH1301") = 1 Then
CLCDTL23N
If Range("G1207") <= Sheets("sheet D").Range("C3") Then
CLCDTL210
End If
End If
Application.ScreenUpdating = True
End Sub

Pilot5000
08-13-2015, 05:49 AM
i tried your suggestion and i still get the same message , now just to let you know the procedure is written on the sheet where i want it to run in the VBA and not as module
i attached 2 PIC of what i get

Paul_Hossler
08-13-2015, 06:17 AM
1. Nothing to go on: no attachment, can't tell which line errors, etc.

2. You can / should have modules like this in a standard module. It will still run on the sheet you identified


now just to let you know the procedure is written on the sheet where i want it to run in the VBA and not as module


3. An observation: The macro that I think you're worried about references a worksheet named "sheet A". The active sheet that I'm guessing you want to run it on is named "Data Input Area". Looking at the sheets in the Project window, I can't see ANY worksheet called "sheet A"

4.
.i have the following code that i converted from lotus123

I don't think 1-2-3 converts to Excel/VBA without a lot more re-write

14152