PC Review


Reply
Thread Tools Rate Thread

activate VBA

 
 
=?Utf-8?B?Z2VlYmVl?=
Guest
Posts: n/a
 
      17th Aug 2007

hi,

i would like to know how i can activate a VBA sub celltoast() when i click a
cell in MS excel. is this possible? if so, how?

thanks in advance,
geebee
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Z2VlYmVl?=
Guest
Posts: n/a
 
      17th Aug 2007
its not working. nothing is hapening. i made sur that the code is in the
ThisWorkBook section instead of a separate module. And I havea sub called
celltoast(). not a macro, but a sub. i even added a messagebox to the code
you gave me, but im not getting a messagebox to appear. what am i doing
wrong?

thanks in advance,
geebee


"Gary''s Student" wrote:

> It is possible. Let's say your macro celltoast is in a standard module. Say
> we want the macro called whenever cell Z100 is clicked.
>
> In the worksheet code area enter:
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If Intersect(Target, Range("Z100")) Is Nothing Then
> Exit Sub
> End If
> Application.EnableEvents = False
> Call celltoast
> Application.EnableEvents = True
> End Sub
>
>
> REMEMBER: the worksheet code area, not a standard module
> --
> Gary''s Student - gsnu200737
>
>
> "geebee" wrote:
>
> >
> > hi,
> >
> > i would like to know how i can activate a VBA sub celltoast() when i click a
> > cell in MS excel. is this possible? if so, how?
> >
> > thanks in advance,
> > geebee

 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      17th Aug 2007
You are being a litle too creative. There should be no sub test().

After you hve right-clicked and selected View Code, erase EVERYTHING you see.

paste in the following:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("Z100")) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Call celltoast
Application.EnableEvents = True
End Sub

Please note that "Worksheet_SelectionChange" is a special name. You can't
change it to test.

Then close the VBA window.

Re-open VBA and then make sure YOUR sub celltoast is in the standard module.
--
Gary''s Student - gsnu200738


"geebee" wrote:

> ok. i now have the following... i right clicked on the sheet name and
> selected "view code". then typed the following:
>
> sub test(byval as target as integer)
>
> if intersect(target, range("a4")) is nothing then
> exit sub
> end if
> application.enableevents = false
> call celltoast
> application.enableevents = true
>
> sub celltoast()
> range("c2").select
> end sub
>
> nothing is happening. am i missgin something?
>
> thanks in advance,
> geebee
>
>
> "Gary''s Student" wrote:
>
> > My sub should go in the worksheet code area, not the ThisWorkbook code area.
> >
> > 1. Erase my code from ThisWorkbook area
> > 2. From Excel, right-click the tab at the bottom of the window and select
> > View Code
> > 3. You should now be in the worksheet code area
> > 4. Paste my stuff in
> >
> > By the way, make sure your code is in a standard module and that it is not
> > Private.
> >
> > --
> > Gary''s Student - gsnu200738
> >
> >
> > "geebee" wrote:
> >
> > > its not working. nothing is hapening. i made sur that the code is in the
> > > ThisWorkBook section instead of a separate module. And I havea sub called
> > > celltoast(). not a macro, but a sub. i even added a messagebox to the code
> > > you gave me, but im not getting a messagebox to appear. what am i doing
> > > wrong?
> > >
> > > thanks in advance,
> > > geebee
> > >
> > >
> > > "Gary''s Student" wrote:
> > >
> > > > It is possible. Let's say your macro celltoast is in a standard module. Say
> > > > we want the macro called whenever cell Z100 is clicked.
> > > >
> > > > In the worksheet code area enter:
> > > >
> > > > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > > > If Intersect(Target, Range("Z100")) Is Nothing Then
> > > > Exit Sub
> > > > End If
> > > > Application.EnableEvents = False
> > > > Call celltoast
> > > > Application.EnableEvents = True
> > > > End Sub
> > > >
> > > >
> > > > REMEMBER: the worksheet code area, not a standard module
> > > > --
> > > > Gary''s Student - gsnu200737
> > > >
> > > >
> > > > "geebee" wrote:
> > > >
> > > > >
> > > > > hi,
> > > > >
> > > > > i would like to know how i can activate a VBA sub celltoast() when i click a
> > > > > cell in MS excel. is this possible? if so, how?
> > > > >
> > > > > thanks in advance,
> > > > > geebee

 
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
Reliably activate PowerPoint, do something, Activate Excel Barb Reinhardt Microsoft Excel Programming 1 4th Dec 2008 09:42 PM
Can't Activate - Clicking Activate Windows Does Nothing :( war59312 Windows Vista General Discussion 1 6th Mar 2007 07:31 AM
What's this? "Press spacebar to activate or enter to activate.... =?Utf-8?B?Rm9yU3VyZQ==?= Microsoft Outlook Discussion 3 13th Apr 2006 09:12 PM
Activate XP Home, then have to activate again after reboot Information Windows XP Basics 3 9th Feb 2006 12:21 AM
Workbook.Activate / Window.Activate problem Tim Microsoft Excel Programming 3 3rd Feb 2006 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:40 PM.