+ Reply to Thread
Results 1 to 7 of 7

A Userform comes from A and B

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    Porto
    MS-Off Ver
    Excel 2010
    Posts
    94

    A Userform comes from A and B

    Hey guys.

    I have an userform that comes from two others userforms.

    I want to make an If that If comes from A happens one thing.

    If comes from B happens other thing.

    Please Login or Register  to view this content.
    can u help me? thanks

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: A Userform comes from A and B

    Declare a public variable in your form e.g.
    Please Login or Register  to view this content.
    then before showing form set its value...

    Please Login or Register  to view this content.
    then use If to check the sender name in Load event...

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: A Userform comes from A and B

    Phew

    This was awkward. I tried declaring a public variable but that didn't seem to help at all.

    But I found two ways that did work.


    First set a cell on a worksheet to be a flag.

    Please Login or Register  to view this content.
    Then you can use that flag to change the way your macro runs.

    Alternatively you can use a text box or a label on the Two Calling Userforms as flags.

    Setting a flag:-

    Please Login or Register  to view this content.
    Using A Flag:


    Please Login or Register  to view this content.

    Sample Spreadsheet Attached.

    Enjoy.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: A Userform comes from A and B

    Sorry Just got the public variable working as well

    So now you have 3 options. The Public variable being the easiest.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-27-2013
    Location
    Porto
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: A Userform comes from A and B

    Well it's not working for me.

    Please Login or Register  to view this content.
    I created the labels for each and put everything as you did.

    It is only working the "Else" part.

    If I put

    Please Login or Register  to view this content.
    and then

    Please Login or Register  to view this content.
    [/CODE]

    only the 2nd part works.

    I've switched them and only the 2nd part works.

    What's the ]If Left(Extrusão.Label7.Caption, 1) for ?

    Cheers, thanks a lot

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    What's do happen when the form is called from A and what's to happen when it's B that does the calling?
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    02-27-2013
    Location
    Porto
    MS-Off Ver
    Excel 2010
    Posts
    94

    Re: A Userform comes from A and B

    problem solved ! solved the problem creating another userform to make it easier, thanks a lot dudes

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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