ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   fractions in forms & cells (not DATES & Decimals) (https://www.excelbanter.com/excel-programming/383995-fractions-forms-cells-not-dates-decimals.html)

T_o_n_y

fractions in forms & cells (not DATES & Decimals)
 
How can I guaranteed that fractions ("5/16" etc) are displayed rather than
dates or decimals in my user forms, Excel cells, and Word bookmarks?

I have tried many things, including formating the Excel cells (Format
Cells...), using Format(data,"# ??/??"), using Application.Text(Cstr(data),
"##/##"), .Numberformat = "# ??/??" and I still have problems.

What I find is that I keep getting Decimals or Dates instead of fractions.
The problem happens both in Excel Cells and when the data in those cells is
transfered to forms generated via Word VBA.

I've resorted to formating everything as text, but that seems to be a poor
solution given Excel's ability to deal with fractions.

Thanks for any tips,
-Tony

NickHK

fractions in forms & cells (not DATES & Decimals)
 
Tony,
Using this:

With Range("A1")
.Value = 0.5
.NumberFormat = "# ??/16"
MsgBox .Text
End With

I see "8/16".

NickHK

"T_o_n_y" wrote in message
...
How can I guaranteed that fractions ("5/16" etc) are displayed rather than
dates or decimals in my user forms, Excel cells, and Word bookmarks?

I have tried many things, including formating the Excel cells (Format
Cells...), using Format(data,"# ??/??"), using

Application.Text(Cstr(data),
"##/##"), .Numberformat = "# ??/??" and I still have problems.

What I find is that I keep getting Decimals or Dates instead of fractions.
The problem happens both in Excel Cells and when the data in those cells

is
transfered to forms generated via Word VBA.

I've resorted to formating everything as text, but that seems to be a poor
solution given Excel's ability to deal with fractions.

Thanks for any tips,
-Tony





All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com