Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Passing Procuedure to Userform

I have a userform that is called from a worksheet event. On initialising I
wish to run a procedure held in a standard module, the procedure changes
depending on the value of the worksheet event.

How do I pass the name of the procedure to the userform initialise event ?

--
Cheers
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Passing Procuedure to Userform

Nigel, I am having a little problem picturing a worksheet event value. Can
you provide the code you have and where each resides?

Mike F
"Nigel" wrote in message
...
I have a userform that is called from a worksheet event. On initialising I
wish to run a procedure held in a standard module, the procedure changes
depending on the value of the worksheet event.

How do I pass the name of the procedure to the userform initialise event ?

--
Cheers
Nigel






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Passing Procuedure to Userform

Hi Nigel,

One way, schematically,

Worksheet module
'----------------------
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target 30 Then
MyInstruction = "a"
ElseIf Target.Value 20 Then
MyInstruction = "b"
ElseIf Target.Value 10 Then
MyInstruction = "c"
Else
'Do something else
End If
End If
UserForm1.Show
End Sub
'-----------------------------

Userform Module
'------------------
Private Sub UserForm_Initialize()
Call TestIt
End Sub

Standard Module
--------------------
Option Explicit
Public MyInstruction As String

'---------------------------
Sub TestIt()
If MyInstruction = "a" Then
MacroA
ElseIf MyInstruction = "b" Then
MacroB
Else
'Do nothing
End If
End Sub

'---------------------------
Sub MacroA()
MsgBox "A"
End Sub

'--------------------------
Sub MacroB()
MsgBox "B"
End Sub

'---------------------------
Sub MacroC()
MsgBox "C"
End Sub


---
Regards,
Norman



"Nigel" wrote in message
...
I have a userform that is called from a worksheet event. On initialising I
wish to run a procedure held in a standard module, the procedure changes
depending on the value of the worksheet event.

How do I pass the name of the procedure to the userform initialise event ?

--
Cheers
Nigel






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Passing Procuedure to Userform

Thanks everyone that has given me some ideas.

--
Cheers
Nigel



"Tushar Mehta" wrote in message
om...
In article , nigel-
says...
I have a userform that is called from a worksheet event. On

initialising I
wish to run a procedure held in a standard module, the procedure changes
depending on the value of the worksheet event.

How do I pass the name of the procedure to the userform initialise event

?


Check out the Application object's Run method. It accepts the name of
the procedure to call as a string argument.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables between Sub and Userform jose luis Excel Programming 8 July 22nd 05 05:20 PM
Passing variables from module to userform Chris Dunigan Excel Programming 4 November 26th 03 09:37 AM
Passing Userform as an argument to a procedure Howard Kaikow Excel Programming 12 October 24th 03 03:24 PM
Userform and passing date values DTM Excel Programming 2 July 23rd 03 04:00 AM
Passing a value to a variable from Userform Neal Steiner Excel Programming 1 July 18th 03 09:12 PM


All times are GMT +1. The time now is 11:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"