+ Reply to Thread
Results 1 to 11 of 11

Sub to call a Private Sub saved as a UserForm

  1. #1
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Sub to call a Private Sub saved as a UserForm

    I am currently trying to setup an advanced employee management dashboard in excel

    However i am encountering a few issues that i hope someone can help with ...

    I have created a shapes in a worksheet and assigned the below macro to it

    Please Login or Register  to view this content.
    The macro i am trying to call is a Private Sub which is saved in the UserForm part of the VBA Window

    But when i click the shape / button it just takes me to the next sheet instead of executing the form ... How can i achieve this ?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sub to call a Private Sub saved as a UserForm

    Is the form open when you try this?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Re: Sub to call a Private Sub saved as a UserForm

    Yes .. If the form isnt open then i am unable to execute the script

    The script is currently running behind the UserForm and as such is not saved in a Worksheet or Module

    Therefore when i right click my buttons i am unable to assign the macro to the button as the script is within the UserForms Code and is also a Private Sub

    How can i make this work ?

    Thanks

    Dave

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sub to call a Private Sub saved as a UserForm

    Dave

    Why do you want to call the sub from a shape on the worksheet?

    Can't you use the cmdProcess button on the userform?

    Am I missing something?

  5. #5
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Re: Sub to call a Private Sub saved as a UserForm

    Quote Originally Posted by Norie View Post
    Dave

    Why do you want to call the sub from a shape on the worksheet?

    Can't you use the cmdProcess button on the userform?

    Am I missing something?
    In that case how do i get the userform to appear in a worksheet ?

  6. #6
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Re: Sub to call a Private Sub saved as a UserForm

    Quote Originally Posted by Norie View Post
    Dave

    Why do you want to call the sub from a shape on the worksheet?

    Can't you use the cmdProcess button on the userform?

    Am I missing something?
    In that case how do i get the userform to appear in a worksheet ?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sub to call a Private Sub saved as a UserForm

    To show a userform the code would look like this.
    Please Login or Register  to view this content.
    So to show UserForm1 it would be this.
    Please Login or Register  to view this content.
    However I thought the was open.

  8. #8
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Re: Sub to call a Private Sub saved as a UserForm

    Quote Originally Posted by Norie View Post
    To show a userform the code would look like this.
    Please Login or Register  to view this content.
    So to show UserForm1 it would be this.
    Please Login or Register  to view this content.
    However I thought the was open.
    When i put that code into the Sheets code it appears as a pop up

    How do i make the form appear as though it was embedded in the worksheet ?

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sub to call a Private Sub saved as a UserForm

    You can't embed a userform in a worksheet.

    Do you still want to interact with the worksheet while the userform is displayed?

  10. #10
    Forum Contributor
    Join Date
    01-28-2014
    Location
    Manchester, UK
    MS-Off Ver
    Microsoft Office 365
    Posts
    127

    Re: Sub to call a Private Sub saved as a UserForm

    Quote Originally Posted by Norie View Post
    You can't embed a userform in a worksheet.

    Do you still want to interact with the worksheet while the userform is displayed?
    Basically what im trying to do is build a performance management dashboard..

    The section i was working on was to add a new employee which you would press the "Add Employee" button then a box would appear

    In this box you would have 3 labels and 3 text boxes ..

    Label 1 - Employee Name
    Label 2 - Department
    Label 3 - Line Manager

    The Process button once pressed when the 3 text boxes where filled in would then paste the data into columns A, B and C on the next empty row in a certain sheet.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sub to call a Private Sub saved as a UserForm

    If that's what you want to do I don't see why you would want/need to call the Click event of the proceed button on the form.

    All you should really have in the code for the shape is code to show the userform.

    Once the user form is up and running it can take care of the rest.

+ 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. Call private sub with variable in its name
    By Willardio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2013, 11:56 AM
  2. Call Private Sub from Add-In
    By Vaw08 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2013, 02:33 PM
  3. call private sub from module
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2009, 10:02 AM
  4. how to call a Private Sub ?
    By dpenny in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2007, 01:15 PM
  5. [SOLVED] IF Statements-call private sub
    By CrimsonPlague29 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-11-2006, 12:00 PM

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