Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Form Routine from Another Workbook Denis[_4_] Excel Programming 1 October 30th 08 04:45 PM
calling a routine to declare variables at start of macro Michael[_48_] Excel Programming 2 August 12th 08 09:43 PM
name of calling routine Smallweed Excel Programming 1 October 2nd 07 05:45 PM
Read directly a returned array in the calling routine Jean-Pierre Bidon Excel Programming 4 December 14th 05 01:40 PM
Keep userform visible, but return control to calling routine Ryan Poth[_2_] Excel Programming 0 August 21st 03 05:28 AM


All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"