+ Reply to Thread
Results 1 to 5 of 5

Passing Values from User Form

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    Pune, India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Passing Values from User Form

    Hi ,

    I have a need of using Userforms, through which i need to get information or data. The gathered data from userform shall be further used for the calculation in the main sub or other sub ..

    so request you for the information ,

    I think , the information is need in two fronts,
    1. passing variables from one sub to another
    2. passing data (i.e., from ComboBox to Main Sub) from userform

    I have simplified the sheet for understanding, I shall attach herewith,

    Thanks in adv for the help !!

    Regards,
    Sri
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Passing Values from User Form

    I'm sorry can you explain a little more what you are trying to do? From what I see yu have accomplishes passing the values selected in the combobox to the second worksheet. I'm not sure why you need to pass a variable but the way to do it is to call the variable outside of the Sub procedures and define it in one of the sub procedures.

    For example:

    Please Login or Register  to view this content.
    To pass a variable into a macro from a userform you would use the Global variable
    For example in the Userform

    Please Login or Register  to view this content.
    In Module1
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-10-2012
    Location
    Pune, India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Passing Values from User Form

    Thank you for the reply,
    I updated the sheet/ code with global variables, even then , i could not able to get the desired output.

    Here i put this way, Say I have a Product ABC with many variants, in which, i have placed 2 variants , Var1 and Var2. If Variant 1 is needed , then user need to click Question1 YES, so that variant 1 can be selected. Similar with Question2 (Variant 2)

    I want to keep a single userform to all the options, so i am changing label by keeping the content in some cell , and copying it from there -- which is also sometimes not working

    If User need variant 1 to be included in the product ABC, he clicks Option button1, then Userform appear with this code.

    Global Variable:
    Please Login or Register  to view this content.
    Userform Initialization Code
    Please Login or Register  to view this content.
    which is somtimes not working !! it is showing the same option1 label!!

    Userform OK button code:
    Please Login or Register  to view this content.
    Variant 1 code : which has to save the VarT content into some other variable as VarT is dynamically changing variable.
    Please Login or Register  to view this content.
    The main code which has to sum up the variants with the base main cost of the product ABC,
    Sub Main()
    Please Login or Register  to view this content.
    The problems that i am facing are :

    1. The label is sometimes not changing to option 2 content , it is still says Option 1
    2. The answer is not desired , answer is coming to 0 , which should be minimum 3 if no variants there !!

    Please help me!!

    Thanks !

    WR
    Sri

  4. #4
    Registered User
    Join Date
    07-10-2012
    Location
    Pune, India
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Passing Values from User Form

    Sry i did not attach the excel sheet ,

    Please find the attached excel sheet with code !!
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    03-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    1,093

    Re: Passing Values from User Form

    Hello there,

    Alright, try the attached revision.

    Thanks!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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