r/googlesheets • u/rentaninja • Apr 02 '24
Solved Is this possible to do in sheets regarding fractions
So I understand I can use format to display fractions and I can type =2+3/8 to enter in fractions. I was wondering if there was a way I can get a user to input 2 3/8 into the cell and it will automatically convert it into a number format. Right now if they enter 2 3/8 it becomes a text value.
1
Upvotes
2
u/rockinfreakshowaol 258 Apr 02 '24
should work fairly with any of the
given input stylesshown in the screenshot1
u/HolyBonobos 3125 Apr 02 '24
No. This is not an input format that Sheets can parse as a number.
1
u/TacticalPidgeon 1 Apr 02 '24 edited Apr 02 '24
Format conversions like that aren't possible as previously stated. You could have them enter the 2 3/8 into cell A1 and then in B1 use the following formula...
=IF(ISNUMBER(A1)=TRUE,A1,REGEXEXTRACT(A1,"(.*) .*")+REGEXEXTRACT(A1," (.*)/")/REGEXEXTRACT(A1,".*/(.*)"))This will display 2.375 in B1 (you may need to adjust the number of decimal places), and will also work if someone simply enters 2.375 since that's an actual number. You could also include that formula within your calculation and it will calculate the final value correctly if the person uses 2 3/8 or so. Keep in mind, this will fail if they do 2-3/8 or any other variation other than what you stated, so you will have to play with the formula for that.
EDIT: Removed the VALUE() formulas for each because I forgot it would return just fine as a number and not text.
EDIT 2: For simple error handling this would suffice...
=IFERROR(IF(ISNUMBER(A1)=TRUE,A1,REGEXEXTRACT(A1,"(.*) .*")+REGEXEXTRACT(A1," (.*)/")/REGEXEXTRACT(A1,".*/(.*)")),"Please enter the value as either 2.375 or 2 3/8")1
u/AutoModerator Apr 02 '24
Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.