Convert formula to VBA equivalent

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
If have a Formula that formats Inches to the nearest 1/2, 1/4, 18 etc

How can I concert that into the VBA equivalent

Formula in cell B13 is =TEXT(INT(A14/12), "0' ;;") & IF(INT(MOD(A14, 12)), INT(MOD(A14, 12)), "") & IF(MROUND(MOD(A14, 1), 1/16), TEXT(MROUND(MOD(A14, 1), 1/16), " ?/#?"), "")

tried

Range("B14") = TEXT(INT(A14/12), "0' ;;") & IF(INT(MOD(A14, 12)), INT(MOD(A14, 12)), "") & IF(MROUND(MOD(A14, 1), 1/16), TEXT(MROUND(MOD(A14, 1), 1/16), " ?/#?"), "")
But that is an invalid VBA
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
How about
VBA Code:
Range("B14").Formula = "=TEXT(INT(A14/12), ""0' ;;"") & IF(INT(MOD(A14, 12)), INT(MOD(A14, 12)), """") & IF(MROUND(MOD(A14, 1), 1/16), TEXT(MROUND(MOD(A14, 1), 1/16), "" ?/#?""), """")"
 
Upvote 0
Have successfully applied the elaborate formula

Here is my question: How can one encourage (force?) the Excel team to include a selection in the Excel cell formatting that effectively does the same, that is:

Provide fraction selection that will reduced to its most common etting

Selection to "nearest 16" or "nearest 8" etc would reduce the entry as follows
Nearest 16 Nearest 8

14/16 to 7/8 6/8 to 3/4
12/16 to 3/4 4/8 to 1/2
10/16 to 5/8 2/8 to 1/4
8/16 to 1/8
6/16 to 3/8
4/16 to 1/4
2/16 to 1/8

I feel that it should be a simple format selection
 
Upvote 0
Sorry, but I don't understand what you're asking.
 
Upvote 0
Here is my question: How can one encourage (force?) the Excel team to include a selection in the Excel cell formatting that effectively does the same, that is:
If you are on 365 (not sure about other versions) on the Help tab there is a send a suggestion link.
I doubt if you will get far though as display issues with fractions have been there for years but you never know..
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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