Calling a subroutine from a module

  • Thread starter Thread starter bower
  • Start date Start date
B

bower

Hi,

I have a subroutine XXXX that I would like to call in the following:

If Not Application.Intersect(Range("C9"), Target) Is Nothing Then
MsgBox "Your code here"
End If

What should I put instead of "Your code here"????

Shouldn't I be able to just put the name of the subroutine (XXXX)? XXX
works fine when it is linked to a button, and the above code seems t
work fine since I ge ta Message Box upon executins that just says "You
code here"

But I can't seem to include the XXXX subroutine.

Pete
 
Peter,

Just put XXXX in place of the MsgBox line. For example,


If Not Application.Intersect(Range("C9"), Target) Is Nothing
Then
XXXX
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Bower,

You should be able to simply use

If Not Application.Intersect(Range("C9"), Target) Is Nothing Then
XXXX
End If

If this code is in a sheet module, the XXXX code should be in the same sheet
module or a public procedure in a general code module.

--

HTH

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

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("C9"), Target) Is Nothing Then
xxxx
End If
End Sub

This in a normal module
Sub xxxx()
MsgBox "Your code here"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top