Can I Assign A User Defined Function To A Cell?

W

Wayne

Can I assign a user defined function to a cell? I have the function
"=AUST_RWCFR_MAText" assigned to a textbox and it works well. However
I don't seem to be able to assign this function to a cell. I get a
#VALUE! error. How can I assign this function to a cell?
 
S

smartin

Wayne said:
Can I assign a user defined function to a cell? I have the function
"=AUST_RWCFR_MAText" assigned to a textbox and it works well. However
I don't seem to be able to assign this function to a cell. I get a
#VALUE! error. How can I assign this function to a cell?


You can fire code when the user selects a certain cell. Place this code
in the /worksheet/ module:

Option Explicit

Private Sub Worksheet_SelectionChange _
(ByVal Target As Range)
' do something if user selects cell J10
If Not Application.Intersect _
(Target, Range("J10")) Is Nothing Then
DoSomething
End If
End Sub



The sub that does the real work can in any module you choose:

Public Sub DoSomething()
MsgBox "You selected J10."
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top