MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Sep 5th, 2003, 08:13 PM   #1
sudhakar682
 
Join Date: May 2003
Location: Chicago
Posts: 163
Default Calling VBA code modules dynamically

Hi,

I am creating some dynamic code for a form(say userform_initialize etc.) using codemodule.

I would like to know how to call that particular module (userform_initialize) to run dynamically using vba code (from my current module).

Thanks in advance,
Sudhakar
sudhakar682 is offline   Reply With Quote
Old Sep 5th, 2003, 08:52 PM   #2
TommyGun
MrExcel MVP
 
TommyGun's Avatar
 
Join Date: Dec 2002
Location: Clear Lake, TX
Posts: 4,202
Default Re: Calling VBA code modules dynamically

Well, you can access procedures inside a UserForm much like you would access methods of other objects. You need to set the scope of the procedure to Public so that it is visible outside of the object. Here is some sample code....

Place this in the userform...

Public Sub FormCode_Test()
****MsgBox "This is how to run code inside a UserForm."
End Sub


Then place this in a standard module...

Sub Test()
****UserForm1.FormCode_Test
End Sub
TommyGun is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT +1. The time now is 08:18 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.