+ Reply to Thread
Results 1 to 8 of 8

Total text boxes to equal 100

  1. #1
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Total text boxes to equal 100

    Hi all,
    I have a userform that has 5 text boxes and 5 list boxes. The user enters in percentages in the text boxes, and these percentages must total to 100% (even if they only use 2 text boxes and the remaining three are blank).

    Please Login or Register  to view this content.
    Right now I am getting a run-time error 'could not find the specified object. I'm stumped on how to fix this! Any help is much appreciated!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Total text boxes to equal 100

    What do you suppose that error means?

    What are the names of the controls?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Total text boxes to equal 100

    IT highlights the line <AllocationTotal = AllocationTotal + Val(Userform1.Controls("Allocation1" & i).Text)> when the run-time error comes up. I am not sure what the controls are as I got this code from another forum.

  4. #4
    Registered User
    Join Date
    04-09-2012
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Total text boxes to equal 100

    cschoyer,

    I know it´s not a perfect code, but works here:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Total text boxes to equal 100

    Thanks Pulsus, however I am getting a type-mismatch error. I know it is probably because my text box are formatted as text and not numbers, but I'm not sure how to switch it!

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-09-2012
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Total text boxes to equal 100

    cschoyer,

    Try This:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Total text boxes to equal 100

    Great, thank you!

  8. #8
    Registered User
    Join Date
    04-27-2012
    Location
    New York, USA
    MS-Off Ver
    Excel 2010
    Posts
    63

    Re: Total text boxes to equal 100

    Now, no matter what I enter, I get the msgbox "Allocation entries must equal 100%." - even if they DO equal 100%!!! Please help!

    Please Login or Register  to view this content.

+ 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