Consulting

Results 1 to 8 of 8

Thread: Solved: Percentage in VBA

  1. #1
    VBAX Regular Darren's Avatar
    Joined
    Feb 2005
    Posts
    98
    Location

    Solved: Percentage in VBA

    Hi Captains

    I have the following questions so get a cup of coffee .... only joking

    I have the following formula on a spread sheet

    =100%-I28/E33

    If i use it in a userform with TextBoxes as follows

    [VBA]Private Sub TextBox25_AfterUpdate()
    TextBox25 = Format(TextBox25, "#,##0.00")
    TextBox26 = Format(TextBox25 * 14 / 100 + TextBox25, "#,##0.00")
    TextBox27 = Format(TextBox26 - TextBox25, "#,##0.00")
    TextBox29 = Format(100% - TextBox24 / TextBox26, "0.00%")
    End Sub[/VBA]

    On the userform;

    It removes the percentage sign and gives a percentage value in the 9000

    or what is the correct procedure to do this calculation.

    The other question is i have 5 calculators in the same workbook as userform's namely and they must open in this order and hide the active sheet in the background. In each Calculator i will place a command Button this button must open the next Calculator.


    1) BasicTerms with button to
    2)OverHeads with a button to
    3)TheBasicFormulas with a button to
    4) SalesTaxcalc with a button to
    5)PromoCalc from the PromoCal a list of at the bottom of the userform where a user can choose a calculator of choice.

    The Greatest of thanks go to Malcolm and XLD for there input in this exercise with them this would not have been possible and on completion i will post it for others to view and use,

    Kindest regards

    Darren
    South Africa

    ps... Xld you have enough points to fly for a month
    Live by Ghandi and learn 1st by "Vbaexpress.com and then by Google" !!!

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Darren
    I have the following formula on a spread sheet

    =100%-I28/E33

    If i use it in a userform with TextBoxes as follows

    [VBA]Private Sub TextBox25_AfterUpdate()
    TextBox25 = Format(TextBox25, "#,##0.00")
    TextBox26 = Format(TextBox25 * 14 / 100 + TextBox25, "#,##0.00")
    TextBox27 = Format(TextBox26 - TextBox25, "#,##0.00")
    TextBox29 = Format(100% - TextBox24 / TextBox26, "0.00%")
    End Sub[/VBA]

    On the userform;

    It removes the percentage sign and gives a percentage value in the 9000

    or what is the correct procedure to do this calculation.
    [vba]

    Private Sub TextBox25_AfterUpdate()
    TextBox25 = Format(TextBox25, "#,##0.00")
    TextBox26 = Format(TextBox25 * 14 / 100 + TextBox25, "#,##0.00")
    TextBox27 = Format(TextBox26 - TextBox25, "#,##0.00")
    TextBox29 = Format(1 - TextBox24 / TextBox26, "0.00%")
    End Sub
    [/vba]

    Quote Originally Posted by Darren
    The other question is i have 5 calculators in the same workbook as userform's namely and they must open in this order and hide the active sheet in the background. In each Calculator i will place a command Button this button must open the next Calculator.

    1) BasicTerms with button to
    2)OverHeads with a button to
    3)TheBasicFormulas with a button to
    4) SalesTaxcalc with a button to
    5)PromoCalc from the PromoCal a list of at the bottom of the userform where a user can choose a calculator of choice.
    Are these calculators all different userforms? If so, just show the first, have a button on that that hides itself, and shows the second, etc.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular Darren's Avatar
    Joined
    Feb 2005
    Posts
    98
    Location
    Hi Bob

    Thank you so much it works or should i say of course it works

    i have nearly completed this little project my last problem is

    When the workbook opens it will hide the the workbook and display the Userform namley "BasicTerms" this is my fist picture. What is important from this image is



    Turnover (Excluding)
    Userform name is = BasicTerms
    label name is = lblTurnoverExcl
    amount = 21,929.82 the amount is not that important as it will change each month.

    I would like to display this automatically amount (21,929.82) when moving to userform OverHeads picture 2 in the box next to Turnover in Rands

    Userform name = OverHeads
    box name = TextBox14

    to summarize

    BasicTerms(is the UserForm) = lblTurnoverExcl to carry the information contained in this label box to the next userform openrd called OverHeads and to place it in TextBox14

    Hope i explained it well.

    Kindest regards

    Darren
    South Africa
    Live by Ghandi and learn 1st by "Vbaexpress.com and then by Google" !!!

  4. #4
    VBAX Regular Darren's Avatar
    Joined
    Feb 2005
    Posts
    98
    Location
    Hi

    Sorry this is image 2
    Live by Ghandi and learn 1st by "Vbaexpress.com and then by Google" !!!

  5. #5
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Have you tried using the Text property of the cells when populating the textboxes?

    That should bring over the formatting.

  6. #6
    VBAX Regular Darren's Avatar
    Joined
    Feb 2005
    Posts
    98
    Location
    Hi Norie

    I have no clue as to what you just said can you maybe give an example

    Darren
    Live by Ghandi and learn 1st by "Vbaexpress.com and then by Google" !!!

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This should get you started
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    VBAX Regular Darren's Avatar
    Joined
    Feb 2005
    Posts
    98
    Location
    Hi Bob

    shewwwwww what a long day

    Thanks Captain applied the examples and perfect.

    I would like to send the completed project to you and malcolm before posting it as a a completed project. To get you thoughts about it being published.

    Darren
    South Africa
    Live by Ghandi and learn 1st by "Vbaexpress.com and then by Google" !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •