Textboxes

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows
Gene

It depends what you mean really.

You could use a textbox to type in something like 1/2 then use code to interpret that as 0.5.
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
Gene

It depends what you mean really.

You could use a textbox to type in something like 1/2 then use code to interpret that as 0.5.

The user will not be typing it in. I want the userform to generate 2 fractions to be displayed - and then the user will choose the larger.

Gene, "The Mortgage Man", Klein
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
I know Native Excel has a format for this - I was wondering if Userforms have the same capability.

Gene, "The Mortgage Man", Klein
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Gene

Why are you using textboxes if there's going to be no user input? Why not use labels?

Also why not load the fractions from a worksheet using the Text property of a cell. That returns the value in the cell as it's formatted on the sheet, though I'm not 100% sure how it would work with the Fraction format.

I'll have a look into it and post back.
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
Gene

Why are you using textboxes if there's going to be no user input? Why not use labels?

Also why not load the fractions from a worksheet using the Text property of a cell. That returns the value in the cell as it's formatted on the sheet, though I'm not 100% sure how it would work with the Fraction format.

I'll have a look into it and post back.


If you are saying that I could format values less than one as fractions in Native Excel (which I know) and then transfer that format into a label on a userform - that would be perfect. I would I do this?

Gene, "The Mortgage Man", Klein
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,344
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Gene

Here's an example.

Put 0.6 in a cell, say A1.

Format that cell as a Fraction, as required.

Then use this code.
Code:
Label1.Caption = Range("A1").Text
I'm not 100% sure how you'll be able to use this in the rest of the code.

You'll somehow need to change it back to a value, if you want to compare it to other values.
 

mortgageman

Well-known Member
Joined
Jun 30, 2005
Messages
2,015
I'm not 100% sure how you'll be able to use this in the rest of the code.

You'll somehow need to change it back to a value, if you want to compare it to other values.

Ah - so you are saying that when I "copy" it into the label, I am only taking the format, not the value. I suppose I can get around this by keeping track of the value "underneath" in excel - but it seems like duplication. Native Excel can keep a fraction value and format in a cell, why can't a Userform keep it in a label or textbox?

Gene, "The Mortgage Man", Klein
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,548
Messages
5,838,038
Members
430,527
Latest member
MyFace2

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
Top