Fraction Format with VBA

ToddG

Board Regular
Joined
Sep 28, 2004
Messages
82
I thought I could get away with a custom cell format to accomplish this but it doesn't appear that it will work that way.

This is the code I tried to do this with:

<font face=Courier New><SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> Range("D:D")
<SPAN style="color:#00007F">If</SPAN> c.Value = "Total" <SPAN style="color:#00007F">Then</SPAN>
c.Offset(0, 1) = Format(Cells(c.Row, "b"), "# ##/##") & " x " & Format(Cells(c.Row, "c"), "# ##/##")
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> c</FONT>

But I am not ending with fractions so obviously my formatting is incorrect.

Any input would be appreciated
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hello Todd,
It's hard to tell your exact intent in that post, but perhaps this will help?
Code:
For Each c In Range("D:D")
  If c.Value = "Total" Then
    With c(1, 2)
      .Value = Cells(c.Row, 2) * Cells(c.Row, 3)
      .NumberFormat = "# ?/?"
    End With
  End If
Next c

{EDIT:}
Multiply column B times column C and put the result in column E formatted as a fraction?
 
Upvote 0
Hi HalfAce,

No, actually i'm joining the value in column B, an "x", and the value in column C.

for example: 4 13/16 x 1 1/4 should be the result.
 
Upvote 0

Forum statistics

Threads
1,211,960
Messages
6,105,081
Members
447,947
Latest member
OX_2005

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
Back
Top