Format as fraction - why doesn't this work?  
Author Message
Whizard





PostPosted: Fri Sep 23 10:09:42 CDT 2005 Top

Excel Programming >> Format as fraction - why doesn't this work?

why doesn't this work?

format(1.5,"0 ??/??")

should return a string "1 1/2", it seems. Instead, it returns "2 ??/??"

What am I missing?

Thanks in advance

Excel328  
 
 
Bernie





PostPosted: Fri Sep 23 10:09:42 CDT 2005 Top

Excel Programming >> Format as fraction - why doesn't this work? Mike,

Apparantly, Format doesn't do fractions, but this does:

Application.Text(1.5, "# ??/??")

HTH,
Bernie
MS Excel MVP




> why doesn't this work?
>
> format(1.5,"0 ??/??")
>
> should return a string "1 1/2", it seems. Instead, it returns "2 ??/??"
>
> What am I missing?
>
> Thanks in advance
>


 
 
VacationsOver





PostPosted: Fri Sep 23 10:24:02 CDT 2005 Top

Excel Programming >> Format as fraction - why doesn't this work? not sure the "text" answer allows math

why not just format cell as fraction :

Selection.NumberFormat = "# ??/??"



> Mike,
>
> Apparantly, Format doesn't do fractions, but this does:
>
> Application.Text(1.5, "# ??/??")
>
> HTH,
> Bernie
> MS Excel MVP
>
>


> > why doesn't this work?
> >
> > format(1.5,"0 ??/??")
> >
> > should return a string "1 1/2", it seems. Instead, it returns "2 ??/??"
> >
> > What am I missing?
> >
> > Thanks in advance
> >
>
>
>
 
 
Bernie





PostPosted: Fri Sep 23 10:45:37 CDT 2005 Top

Excel Programming >> Format as fraction - why doesn't this work? The worksheet function TEXT takes a number and returns a formatted text string.
Selection.Numberformat would work fine, if the variable were actually being stored in the
spreadsheet and not manipulated in VBA.

HTH,
Bernie
MS Excel MVP




> not sure the "text" answer allows math
>
> why not just format cell as fraction :
>
> Selection.NumberFormat = "# ??/??"
>

>
>> Mike,
>>
>> Apparantly, Format doesn't do fractions, but this does:
>>
>> Application.Text(1.5, "# ??/??")
>>
>> HTH,
>> Bernie
>> MS Excel MVP
>>
>>


>> > why doesn't this work?
>> >
>> > format(1.5,"0 ??/??")
>> >
>> > should return a string "1 1/2", it seems. Instead, it returns "2 ??/??"
>> >
>> > What am I missing?
>> >
>> > Thanks in advance
>> >
>>
>>
>>


 
 
Mike





PostPosted: Fri Sep 23 11:29:01 CDT 2005 Top

Excel Programming >> Format as fraction - why doesn't this work? Thanks! That is exactly what I needed.

Mike



> Mike,
>
> Apparantly, Format doesn't do fractions, but this does:
>
> Application.Text(1.5, "# ??/??")
>
> HTH,
> Bernie
> MS Excel MVP
>
>


>> why doesn't this work?
>>
>> format(1.5,"0 ??/??")
>>
>> should return a string "1 1/2", it seems. Instead, it returns "2 ??/??"
>>
>> What am I missing?
>>
>> Thanks in advance
>>
>
>