PC Review


Reply
Thread Tools Rate Thread

Calling a VBA sub routine

 
 
Howard
Guest
Posts: n/a
 
      21st Dec 2008
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 With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      21st Dec 2008

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
(E-Mail Removed)
"Howard" <(E-Mail Removed)> wrote in message
news:E89CBF41-13AC-42F6-971D-(E-Mail Removed)...
> 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 With Quote
 
Mike H
Guest
Posts: n/a
 
      21st Dec 2008
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 With Quote
 
Howard
Guest
Posts: n/a
 
      21st Dec 2008
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 With Quote
 
Don Guillett
Guest
Posts: n/a
 
      21st Dec 2008
Post YOUR code


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Howard" <(E-Mail Removed)> wrote in message
news:ECE40553-9584-4868-9ED7-(E-Mail Removed)...
> 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 With Quote
 
Howard
Guest
Posts: n/a
 
      22nd Dec 2008
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
> (E-Mail Removed)
> "Howard" <(E-Mail Removed)> wrote in message
> news:ECE40553-9584-4868-9ED7-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a VBA Routine MarkS Microsoft Access VBA Modules 1 13th Dec 2007 02:09 AM
name of calling routine =?Utf-8?B?U21hbGx3ZWVk?= Microsoft Excel Programming 1 2nd Oct 2007 05:45 PM
calling sub-routine Lodewijk Microsoft Access Form Coding 2 30th Mar 2005 09:21 PM
calling sub-routine Lodewijk Microsoft Access Forms 2 30th Mar 2005 09:21 PM
calling sub-routine Lodewijk Microsoft Access 2 30th Mar 2005 09:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 PM.