• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run-time error '424' - Object required

Igor R.

New Member
Hello!
I'm struggling to realize what i am doing wrong.

I have macro (let's call it macro1) that run macro from another workbook (macro2).
Years Macro2 was run perfectly from it's original file.
But when I tried first time to run macro2 from Macro1, macro2 stopped to run and started make the above error, even though I go back and try to run macro 2 from its original file.

Here is some code in macro2 that make the above error:
Code:
'Define As Global Variables because i use them in the whole project'
Global wsSim, wsRes, wsOut, wsPrm As Worksheet

'Defining the Vars in the main Sub:
    Set wb = ThisWorkbook
    Set wsSim = wb.Worksheets("Simulator")
    Set wsRes = wb.Worksheets("Results")
    Set wsOut = wb.Worksheets("Output")
    Set wsPrm = wb.Worksheets("Params")


'Defining vars in Sub:
Dim start_tranche As Integer
start_tranche = wsPrm.Range("start_tr").Value ' At this Line i get the error'

'But if i change code like this it runs fine:'
start_tranche = ThisWorkbook.Worksheets("Params").Range("start_tr").Value

What am i doing wrong?
I want to use vars - wsPrm atc'
 
Last edited:
Igor R.
okay ...
Dim start_tranche As Integer
but next, You have used "start_tr" ... which is unknown string.
start_tranche = wsPrm.Range("start_tr").Value
You've given only few lines from somewhere.
Is that enough to guess - what else do You have there?
 
You need to clarify exactly where those code lines are.

Also, you should be aware that this:

Code:
Global wsSim, wsRes, wsOut, wsPrm As Worksheet

only declares wsPrm as a Worksheet object. The others are all variants. You need to specify the type for every variable (and note that Global is deprecated in favour of Public these days):

Code:
Public wsSim As Worksheet, wsRes As Worksheet, wsOut As Worksheet, wsPrm As Worksheet
 
You need to clarify exactly where those code lines are.

Also, you should be aware that this:

Code:
Global wsSim, wsRes, wsOut, wsPrm As Worksheet

only declares wsPrm as a Worksheet object. The others are all variants. You need to specify the type for every variable (and note that Global is deprecated in favour of Public these days):

Code:
Public wsSim As Worksheet, wsRes As Worksheet, wsOut As Worksheet, wsPrm As Worksheet
Thank you very much!
It work this way now.
 
Back
Top