+ Reply to Thread
Results 1 to 4 of 4

passing to a UserForm Initialise event

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    passing to a UserForm Initialise event

    I have loaded a table of data into an array in order to perform a search.
    When the search is successful I want to display the relevant row of data in a userform.
    I was hoping to use the initialise event of the userform to do this. When I try though, I get the message that the array is not seen.
    There is no way with my code that I can pass the array. How should I tackle this? Somehow I need to pass the array and the value of j to the form.
    Please Login or Register  to view this content.
    John

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    2016 Win10
    Posts
    7,164

    Re: passing to a UserForm Initialise event

    Easy Hacky way:
    Please Login or Register  to view this content.
    Last edited by Kyle123; 01-06-2015 at 08:30 AM.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    19,777

    Re: passing to a UserForm Initialise event

    Simplest route is to declare the array outside of the routine and make it public. This way the initial event will be able to access it.

    Better approach is to add a public routine to the userform that you can pass the array into.
    You would need to load the userform with code, run the routine to populate controls and then show the userform.

    So code would be more like,
    Please Login or Register  to view this content.
    The InitializeMyForm code is placed in the userform2 code module.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    2016 Win10
    Posts
    7,164

    Re: passing to a UserForm Initialise event

    ^^ and that's the non hacky way

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Userform multipage control - exit event not firing or event order
    By jane serky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 10:23 AM
  2. freezing and passing SelectionChange event value
    By Hammer_757 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2012, 10:06 AM
  3. Passing ComboBox from event procedure to module?
    By FaultlineXR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2011, 06:09 PM
  4. Workbook_BeforeClose Event - passing arguments
    By pmguerra in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-09-2008, 10:24 AM
  5. Userform initialise help!
    By justchris in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-21-2005, 05:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1