Populating a TextBox with a % Value taken from worksheet cells

cmerrick

Board Regular
Joined
Jun 8, 2017
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hi there,

I have a calculation taking place on a work sheet - a calculation to work out a percentage.

=IFERROR(SUM(D6/D5),0)

In this example I'm using Loan (£100,000) / Property Value (£200,000) = 0.5 (formatted to %) = 50%

All I want to do it have my user form pull through the value of '50%' but it keeps pulling through '0.5'

I'm using a command button to trigger the below code - this populates a textbox with the value of 0.5

I need something that basically converts the 0.5 value to 50%

Code:
Private Sub CalculateBu_Click()


LTVTB.Value = Sheets("Form Validation").Range("D9")




End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi there,

I have a calculation taking place on a work sheet - a calculation to work out a percentage.

=IFERROR(SUM(D6/D5),0)

In this example I'm using Loan (£100,000) / Property Value (£200,000) = 0.5 (formatted to %) = 50%

All I want to do it have my user form pull through the value of '50%' but it keeps pulling through '0.5'

I'm using a command button to trigger the below code - this populates a textbox with the value of 0.5

I need something that basically converts the 0.5 value to 50%

Code:
Private Sub CalculateBu_Click()


LTVTB.Value = Sheets("Form Validation").Range("D9")




End Sub


Hi,
I provided a solution to this question in your other post here:https://www.mrexcel.com/forum/excel...-through-figures-excel-userform-realtime.html


Note: I have assumed that the range D9 is formatted as % in which case, using the Range.Text property should return what you see in the cell to your textbox

which you have not responded to solution offered in the thread to confirm if it does what you want.


Dave
 
Last edited:
Upvote 0
Oh I am sorry, I must have missed that email!

I've checked back over the previous thread and this seems like a slightly different question - I've changed process now so that the calculation and display of the % value is 'triggered' by the CommandButton now rather than attempting to get it to update as and when the initial figures are defined in real time.

The calculation takes place on the work sheet =IFERROR(SUM(D6/D5),0) - This gives me 0.5 (formatted to %) = 50% in the worksheet so yes, D9 is formatted as %

All I'm trying to do is pull though '50%' to my text box 'LTVTB'

 
Upvote 0
Oh I am sorry, I must have missed that email!

I've checked back over the previous thread and this seems like a slightly different question - I've changed process now so that the calculation and display of the % value is 'triggered' by the CommandButton now rather than attempting to get it to update as and when the initial figures are defined in real time.

The calculation takes place on the work sheet =IFERROR(SUM(D6/D5),0) - This gives me 0.5 (formatted to %) = 50% in the worksheet so yes, D9 is formatted as %

All I'm trying to do is pull though '50%' to my text box 'LTVTB'


Question may be different but solution I stated in last thread should be the same.
You use the Range.Text property to return what you see in the cell rather than it's underlying value

Rich (BB code):
LTVTB.Value = Sheets("Form Validation").Range("D9").Text

Dave
 
Upvote 0
Alright so is the code used in the CommandButton Sub as below?

Code:
Private Sub CalculateBu_Click()
LTVTB.Value = Sheets("Form Validation").Range("D9").Text
End Sub

edited for typo
 
Last edited:
Upvote 0
It worked - my project is almost completed so thank you very much.

If anyone is interested in seeing the code I can share but it's probably nothing special to you guys.
 
Upvote 0
It worked - my project is almost completed so thank you very much.

If anyone is interested in seeing the code I can share but it's probably nothing special to you guys.


Gals you resolved & all now working.

Don't be too hard on yourself we all have to start somewhere - all programmers have their preferred coding style & all can make mistakes.

Would be worth your while reading up VBA best coding practices - some of the basics.

- Always use Option Explicit, usually use Option Private Module. (this forces variables to be declared)
-Declare your variables with required scope & data type
- Use meaningful names for all procedures and variables.
- Keep Procedures short as possible

etc etc

Dave
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,118
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top