+ Reply to Thread
Results 1 to 12 of 12

VBA Userforms Help

  1. #1
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    VBA Userforms Help

    Program: Excel 2007

    Hello I am trying to do a lot of lines of coding & I have split them up into several userforums. How do I activate one userform if the first one does not match.

    Basically I have this line of code going over many times with the numbers changed:
    Please Login or Register  to view this content.
    You have 6 text-boxes with numbers you can put in but I can only go up with this line of code to the value of 3 & I need to go to the value of 6 so I made another userform, but I don't know how to tell the macro to go to the 2nd userform if the values for all the text-boxes is 4 & over.

    Let me know if I need to make anything more clear or if you have questions & thanks in advance for the help!
    Last edited by White_Path; 10-24-2011 at 10:38 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userforms Help

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Userforms Help

    Sorry I edited it thanks.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userforms Help

    I don't understand why you have different userforms, that's just making work not to mention trying to do calculations with that.

  5. #5
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: VBA Userforms Help

    put a sample workbook up and I will take a look, but like roy said why would you use different userforms?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userforms Help

    The calculations are trying to use textboxes from different userforms. You can't calculate using a textbox because it's default is a string, you need to convert the string to a value like Long or Double

  7. #7
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Userforms Help

    It works fine for this set of the code, but adding in the rest makes it far too long. I use text-boxes because the calculations are different for each set.

    The code I am using I get from Tristian Class A Sheet & the text-boxes direct it to tables under Tristian Planet Income Sheet. I have far too many characters for the macro & I have several more sheets to go as you can probably tell so I think I need to create a
    Please Login or Register  to view this content.
    but I am not quite sure if that is right or the easiest way to do it. Once, I know what to do I can do it & I do realize that it will be quite a bit of work. The code is based off of the numbers in Text-box 3 so that is why I have that above.
    Attached Files Attached Files
    Last edited by White_Path; 10-24-2011 at 03:39 PM.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userforms Help

    I can't see any reason for two UserForms, a MultiPage control on one userform would be much simpler.

    As I said, you can't use the TextBox entries for calculations , they must be converted to values, e.g.
    Please Login or Register  to view this content.
    You might want to consider ComboBoxes instead of TextBoxes to ensure correct entries are made and using meaningful names for the controls would make the code easier to understand

  9. #9
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Userforms Help

    Ok thank you I will try that.

  10. #10
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Userforms Help

    Ok sorry maybe I am not being clear. The code that I am using is far too long for the command button. I have maybe 100k+ worth of code lines & I was thinking of breaking it up into 2-4 user-forms & linking the command buttons between them. Basically I just need someway of putting in my whole code together either by breaking it up someway or by lengthening the amount of code I can do through a command in the command-button. The code & text-boxes work fine I just can't fit all the code together. Does that make more sense?

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Userforms Help

    It doesn't make sense to have that many lines of code, what exactly are you doing

    Your code will not perform a calculation as it is written now.

  12. #12
    Registered User
    Join Date
    10-24-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: VBA Userforms Help

    I am using it for a board game that I play so I don't have to calculate everything everytime. It does do calculations I already know that. When you punch in a number into the text-box it tells the form to go to cell whatever & pull the number there. You do that for all the text-boxes & then it gives you a number. IE: You put in A for text-box one & that tells you the class then you put in 3 for text-box 2 & that tells it to look under C4 & use that number. 3 for text-box 3 & it looks under the range or E4. Here is the code for if it was all ones:

    Please Login or Register  to view this content.
    I have tested it & just tested it again & it works, but because I have a large table I have a lot of code to cover all of it (67 separate cells not including all the permutations). I need to do this for all 6 nations, but they will all have separate macros I just need the Class A-F for each nation together). Does that help at all?

+ 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