running a macro in another macro

  • Thread starter Thread starter BM
  • Start date Start date
B

BM

I have been trying to set up a macro which will run
another macro if a certain condition is met. Previously, I
have been given the following advice:
Sub StartHere()
If Range("C1").Value =1 Then
RunOtherMacro
End If
End Sub

Sub RunOtherMacro()
msgbox "Got Here"
End Sub

However, I am certainly no macro expert and I am still
experiencing problems. I am getting a message saying "sub
or function not defined" and it is highlighting
RunOtherMacro in the third line above.

I have changed RunOtherMacro to the name of the other
macro that I actually need to run, but I still get "sub or
function not defined".

When I look on Visual Basic Help it tells me that I need
look at the references and map DAO350.dll. I have done
this and it makes no difference to the error I am getting.

Can anybody help?

Thanks
 
That seems fine. Show the real code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Here is the real code.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/04/2004 by bmcgraw
'

'Sub StartHere()
If Range("'Look up'!R8C6>0").Value = 1 Then
RunMacro2
End If
End Sub

'Sub RunMacro2
MsgBox "Got here"
End Sub
 
Thanks. Now getting new error message

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/04/2004 by bmcgraw
'

'Sub StartHere()
If Range("'Look up'!R8C6>0").Value = 1 Then
RunMacro2
End If
End Sub

Sub RunMacro2()
MsgBox "Got here"
End Sub

The line:

If Range("'Look up'!R8C6>0").Value = 1 Then

is being highlighted and get message:

run time error '1004'

Method 'Range' of object'_Global failed.

Any ideas?

Many thanks
 
Hi

just use the following code(delete everything else form
your module):

option explicit
Sub StartHere()
If Range("'Look up'!R8C6").Value = 1 Then
RunMacro2
End If
End Sub

Sub RunMacro2()
MsgBox "Got here"
End Sub

Assumption: the sheet 'look up' exists
 
Hi

Thanks. I have copied the suggestion below straight in
(deleting everything else). Still getting:

The line:
The sheet Look up definately exists. I cant understand why
this wont work. Any more ideas?

thanks
 
Frank suggested

If Range("'Look up'!R8C6").Value = 1 Then

not

If Range("'Look up'!R8C6>0").Value = 1 Then

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Now working. Thanks Bob and Frank.

-----Original Message-----
Frank suggested

If Range("'Look up'!R8C6").Value = 1 Then

not

If Range("'Look up'!R8C6>0").Value = 1 Then

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 
Back
Top