Results 1 to 4 of 4

Thread: Is it possible to add a parameter in the UserForm_Initialize() function ?

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    33
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Is it possible to add a parameter in the UserForm_Initialize() function ?

    Hello everyone,

    So, yeah, the question is in the title. Can I for instance write something like
    Private Sub UserForm_Initialize(rowCount As Integer)
    and call it in my macro with
    myControl.UserForm_Initialize(rowCount)
    and expect it to work ?

    Thanks you for reading,

    Marie

  2. #2
    Board Regular gallen's Avatar
    Join Date
    Jun 2011
    Location
    Manchester UK
    Posts
    1,906
    Post Thanks / Like
    Mentioned
    21 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Is it possible to add a parameter in the UserForm_Initialize() function ?

    In short no. I don't believe you can.

    However you can add public variables to the form and then set them when you create the instance of the form.

    - forum use guidelines, forum rules and terms of use

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


  3. #3
    MrExcel MVP
    Moderator
    Fluff's Avatar
    Join Date
    Jun 2014
    Location
    Chippenham
    Posts
    29,229
    Post Thanks / Like
    Mentioned
    483 Post(s)
    Tagged
    49 Thread(s)

    Default Re: Is it possible to add a parameter in the UserForm_Initialize() function ?

    Another option would be to send the value to a control on the userform like
    Code:
       UserForm1.TextBox1.Value = 123
       UserForm1.Show
    or use the Tag property
    Code:
       UserForm1.Tag = 123
       UserForm1.Show
    - Posting Data try one of these tools
    - Posting guidelines, forum rules and terms of use
    - Read the FAQs

    Running Office 365 on Win 10

  4. #4
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,993
    Post Thanks / Like
    Mentioned
    53 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Is it possible to add a parameter in the UserForm_Initialize() function ?

    If you need the value to be available to the Initialize event, rather than say the Activate event, you'd need to use a public variable (declared in a normal module, not in the userform).

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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