View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default VBA Auto_Activate

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.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"PaulD"

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