Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / June 2006

Tip: Looking for answers? Try searching our database.

VBA Auto_Activate

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PaulD - 25 Jun 2006 02:14 GMT
I've been having a real (tho stupid) problem w getting Auto_Activate to work
with sheets in my Workbook.
I create a name within an active sheet (say Sheet1) called "Auto_Activate".
I refer the name to a procedure (say OnActivate) that I have written within
Sheet1.

I get the error MsgBox "Can't find OnActivate".

So I've additionally tried the following permutations:
- Put OnActivate in Module1, ThisWorkbook (in addition to Sheet1).
   (and verified its existence in all three using object browser)
- Changed the syntax in "Refers to" box to try e.g.
                              Sheet1.OnActivate
                              Sheet1!OnActivate
- Renamed Sheet1 to "FirstSheet" and repeated above using
                              e.g. FirstSheet!OnActivate

I've tried to methodically try every permutation I can think of and no luck.
After trying for > 5 hours, I'm giving up and asking for help.

Doesn't what I've described seem to be the right way to go?
[I knew I only had one brain cell left, but, till now, it seemed to be working
just fine.....]
Jim Cone - 25 Jun 2006 03:19 GMT
I am not sure what you are trying to do.
It appears you are trying to call a Sub routine from a worksheet cell
using a name that refers to the procedure's name.
That won't work, but that shouldn't be news to you.
However, you can call a function with a formula.  

Functions return a value and that value can be shown in a worksheet cell.
If you were to have a function procedure in a standard module like...

Function GetNumber(ByRef strColumn As String) As Long
  GetNumber = Columns(strColumn).Column
End Function
'-----------------
Then if you enter this formula in worksheet cell...
=getnumber("AB")
You would have the column number of Column("AB") displayed in the
cell as... 28

If you want to call a sub routine from the worksheet, one way would be
to add a button from the Forms toolbar and "attach" the sub's name
to the button.
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

"PaulD"
<PaulD@discussions.microsoft.com>
wrote in message
I've been having a real (tho stupid) problem w getting Auto_Activate to work
with sheets in my Workbook.
I create a name within an active sheet (say Sheet1) called "Auto_Activate".
I refer the name to a procedure (say OnActivate) that I have written within
Sheet1.
I get the error MsgBox "Can't find OnActivate".
So I've additionally tried the following permutations:
- Put OnActivate in Module1, ThisWorkbook (in addition to Sheet1).
   (and verified its existence in all three using object browser)
- Changed the syntax in "Refers to" box to try e.g.
                              Sheet1.OnActivate
                              Sheet1!OnActivate
- Renamed Sheet1 to "FirstSheet" and repeated above using
                              e.g. FirstSheet!OnActivate
I've tried to methodically try every permutation I can think of and no luck.
After trying for > 5 hours, I'm giving up and asking for help.
Doesn't what I've described seem to be the right way to go?
[I knew I only had one brain cell left, but, till now, it seemed to be working
just fine.....]

Norman Jones - 25 Jun 2006 06:41 GMT
Hi Paul,

Perhaps what you seek is the Worksheet_SelectionChange event or, possibly,
the Worksheet_Activate event.

For more information on these and other event procedures, see Chip Pearson's
overview at:

       http://www.cpearson.com/excel/events.htm

---
Regards,
Norman

> I've been having a real (tho stupid) problem w getting Auto_Activate to
> work
[quoted text clipped - 24 lines]
> working
> just fine.....]
PaulD - 25 Jun 2006 18:23 GMT
Norman,
Thanks for taking the time to help out.  I've been using a book by Jeff Webb
and,
after reading your post I took a look at it's publication date.  1996!  Yikes!
In there he listed 4 "auto" procedures.

                                Auto_Open
                                Auto_Close       (for Workbooks)
and                            Auto_Activate
                                 Auto_Deactivate  (for Worksheets).

The article you pointed out is the way I will go. (Haven't done it yet but
I'm sure its the right thing).  BYW  Auto_Open and Auto_Close still seem to  
work w/ Excel 2003.

Jim-- Thanks to you also.  If you look a Norms posting, you'll see that I
wasn't trying
to associate a procedure w/ a range or cell but with the action of
activating an object such as a Worksheet.
 
P.S. I'm awaiting delivery of 3 or 4 programming guides from Amazon---on
Excel 2003!  No more foolishness I hope!


 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.