Textboxes

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,362
Office Version
365
Platform
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
75,362
Office Version
365
Platform
Windows
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
75,362
Office Version
365
Platform
Windows
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
 

Forum statistics

Threads
1,081,526
Messages
5,359,279
Members
400,523
Latest member
ExcelNewbie98

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top