How to use an Userform [VBA] multiple times in excel sheet

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question

    mrexcel.com/board/threads/how-…s-in-excel-sheet.1172378/

    I am using Userform1 multiple times in different Excel worksheets. But, If I select Checkbox in the first Userform then another Userforms checkbox automatically selected. How can I separate them?

    I'm a beginner in coding so do not have much idea how can I segregate them to perform individually.

    Code
    1. Private Sub CommandButton7_Click()
    2. UserForm1.Show
    3. End Sub
    4. Private Sub CommandButton8_Click()
    5. UserForm1.Show
    6. End Sub

    [Blocked Image: https://i.stack.imgur.com/3uquF.png]

  • Thank You.. Here is my sample file for better understanding. You can check when I select optionbutton in Sheet1 then the same optionbutton automatically gets selected in Sheet2. I want both Cmdbutton and Userform perform individually

    Files

  • Roy, hope you would have clicked both "SELECT" button in "Sheet1" & "Sheet2"

    I want to use the same "Userform9" for both CommanButton's "SELECT" in each sheet

    Suppose, If I click on "Select" Button at "Sheet1" then Userform9 will open. I can select any Option/Radio Button in Userform9 and save/close it.

    The issue is when I click on "Select" Button at "Sheet2" then Userform9 opens, but the same Option/Radio Button selected by default that I had selected in "Sheet1".


    If I select other Option/Radio Button at "Sheet2" in Userform9 and save/close it, then the same thing happens with "Sheet1" Userform.

    In "Sheet1" Option/Radio Button selected by default that I have selected in "Sheet2".


    I know I can make replica of Userform with different name which will work perfectly. But, I have several sheets in my original Workbook.

    This is just a sample to understand my issue.

    I want know with the same Userform , How can I perform them individually. I mean If I do some change in "Sheet1" Userform that should not reflect or select any Option/Radio Button in "Sheet2" Userform. Both should perform separately.


    Hope you have solution for me :)

  • That's because you are hiding the userform, not unloading it.


    Change


    Code
    1.  Private Sub CancelButton_Click()
    2. UserForm9.Hide
    3. End Sub
    4. Private Sub CommandButton1_Click()
    5. UserForm9.Hide
    6. End Sub

    to

    Code
    1. Private Sub CancelButton_Click()
    2. Unload Me
    3. End Sub
    4. Private Sub CommandButton1_Click()
    5. Unload Me
    6. End Sub
  • I suggest you read the Forum Rules before we continue.


    Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the URL from the address bar in your browser) to the cross-post. We are here to help so help us help you!




    Read this to understand why we ask you to do this



    https://www.excelguru.ca/content.php?184


    Let me know when you have and we can continue.