format fractions in VBA

E

Eldon Lehman

Is there an undocumented method of formatting numbers in textboxes as
fractions instead of decimals. Excel uses:
.NumberFormat = "# ??/16"
to get to the closest sixteenth. If none is available I will use a
Select Case to change the text display since only a few are needed to
show drill bit size increments through one inch.
Thank you,
Eldon
 
S

Steve Rindsberg

Eldon Lehman said:
Is there an undocumented method of formatting numbers in textboxes as
fractions instead of decimals. Excel uses:
.NumberFormat = "# ??/16"
to get to the closest sixteenth. If none is available I will use a

No (and a pity, too).

But you could creat a list or table in Excel then copy/paste special/link it to
PowerPoint and get the benefit of Excel's formatting.
 
S

Steve Rindsberg

Eldon Lehman said:
.NumberFormat = "# ??/16"

On further thought, it occurred to me that something like this might do it:

Sub PracticeDrill()

Dim DrillGauge As Double
DrillGauge = 1.25


MsgBox Format(Int(DrillGauge), "#") _
& " and " _
& (DrillGauge - Int(DrillGauge)) / (1 / 16) _
& "/16"


End Sub
 
E

Eldon Lehman

Steve Rindsberg said:
On further thought, it occurred to me that something like this might do it:

Sub PracticeDrill()

Dim DrillGauge As Double
DrillGauge = 1.25


MsgBox Format(Int(DrillGauge), "#") _
& " and " _
& (DrillGauge - Int(DrillGauge)) / (1 / 16) _
& "/16"


End Sub

Steve, that worked perfectly. I don't speak variables as fluently as
you do, but always look forward to an opportunity to see how they can
make code work so efficiently.
Many Thanks!
 
S

Steve Rindsberg

Glad to help, Eldon.


Steve, that worked perfectly. I don't speak variables as fluently as
you do, but always look forward to an opportunity to see how they can
make code work so efficiently.
Many Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top