Calling a VBA sub routine

H

Howard

Question for all you guru's. Is it possible to put a VBA sub routine in a
module, and then write a sub on sheet(1) that calls the module sub? I have a
sub routine in a module which works when run manually, but I really want it
to work when ever a cell on sheet 1 is changed. I already have a sub routine
on sheet 1 now.
 
D

Don Guillett

I assume you are saying that you already have a worksheet_change event. You
should always post your code for comments. You can also have this. Perhaps a
restriction

if target.address="$A$2" then call subnamehere
 
M

Mike H

Hi,

yes you can do that

worksheet code
Private Sub Worksheet_Change(ByVal Target As Range)
mysub
End Sub

and in a general module
Sub mysub()
MsgBox "Hello world"
End Sub

Mike
 
H

Howard

Thanks to both. I'm kind of new to VBA, but these ideas will help a lot.
I'll give them a try.
 
H

Howard

Don Guillett:
Sorry about posting the code. I ran out of time today. I'll try your
suggestion, and if I need to post again, I'll be sure and include the code
I'm working with. Thanks again for you assistance.
 

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

Top