PDA

View Full Version : Solved: Percentage in VBA



Darren
08-25-2007, 01:02 PM
Hi Captains

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

I have the following formula on a spread sheet

=100%-I28/E33

If i use it in a userform with TextBoxes as follows

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

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:beerchug:

Bob Phillips
08-25-2007, 02:09 PM
I have the following formula on a spread sheet

=100%-I28/E33

If i use it in a userform with TextBoxes as follows

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

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.



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



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.

Darren
08-26-2007, 11:40 AM
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

Darren
08-26-2007, 11:44 AM
Hi

Sorry this is image 2

Norie
08-26-2007, 12:18 PM
Have you tried using the Text property of the cells when populating the textboxes?

That should bring over the formatting.

Darren
08-26-2007, 12:30 PM
Hi Norie

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

Darren

Bob Phillips
08-26-2007, 03:36 PM
This should get you started

Darren
08-27-2007, 02:35 PM
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