ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling a VBA sub routine (https://www.excelbanter.com/excel-programming/421587-calling-vba-sub-routine.html)

howard

Calling a VBA sub routine
 
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.
--
Howard

Don Guillett

Calling a VBA sub routine
 

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Howard" wrote in message
...
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.
--
Howard



Mike H

Calling a VBA sub routine
 
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


"Howard" wrote:

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.
--
Howard


howard

Calling a VBA sub routine
 
Thanks to both. I'm kind of new to VBA, but these ideas will help a lot.
I'll give them a try.
--
Howard


"Mike H" wrote:

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


"Howard" wrote:

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.
--
Howard


Don Guillett

Calling a VBA sub routine
 
Post YOUR code


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Howard" wrote in message
...
Thanks to both. I'm kind of new to VBA, but these ideas will help a lot.
I'll give them a try.
--
Howard


"Mike H" wrote:

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


"Howard" wrote:

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.
--
Howard



howard

Calling a VBA sub routine
 
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.
--
Howard


"Don Guillett" wrote:

Post YOUR code


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Howard" wrote in message
...
Thanks to both. I'm kind of new to VBA, but these ideas will help a lot.
I'll give them a try.
--
Howard


"Mike H" wrote:

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


"Howard" wrote:

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.
--
Howard





All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com