Copy link to clipboard
Copied
I was given an excel sheet to format, and now the client has asked me to eliminate the second decimal number (ex change 10.70% -> 10.7%) I wanted to know if someone knew how to specifically target that second number via grep styles or Find/replace. Thanks is advanced, this would help immensely.
You cannot use GREP Styles to remove content. For that you must use GREP in Find/Change.
Find: \.(\d)\d%
Change: .$1%
Copy link to clipboard
Copied
You cannot use GREP Styles to remove content. For that you must use GREP in Find/Change.
Find: \.(\d)\d%
Change: .$1%
Copy link to clipboard
Copied
You cannot use GREP Styles to remove content.
By @Scott Falkner
You can't "remove" - but you can "hide"...
Copy link to clipboard
Copied
You can't "remove" - but you can "hide"...
By @Robert at ID-Tasker
True. You could use the Find expression in a GREP Style and apply a character style that uses a very small point size plus a very small scale percentage, which would effectively make the characters disappear. 0.1 point, with 1% horizontal scale and no fill colour would do the trick.
Copy link to clipboard
Copied
Thanks Scott! That was perfect! (and stopped me from manually deleting 300 zeros)
Copy link to clipboard
Copied
Looks like you ALWAYS have "0%"? Why not replace "0%" with "%"?
Or go with @Scott Falkner's much more universal approach.
Copy link to clipboard
Copied
My method will only remove the final digit before the %, it will not round. Rounding would require a more complicated expression at best and more likely is not possible. I mean, you could probably write an expression smart enough to round 12.87% up to 12.9% but rounding 19.97% up to 20.0% seems non-doable.
Copy link to clipboard
Copied
Something like this?
"19.97% up to 20.0%" - only scripting or few separate GREPs - depends on how much you want to round up - only 19.xx -> 20.00 or 15.xx-19.xx -> 20.00
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It would have to round every possibility. X.0(5-9) to X.1, X.1(5-9) to X.2, X.2(5-9) to X.3, X.3(5-9) to X.4, etc. Then repeat for every possibiliy of X.9(5-9) to X+1.0.
Now add for every X9.0(5-9) to [X=1]0.0 (e.g. 29.96 rounds to 30.0). Even if you did plug in all those GREP expressions I bet the document would run like molasses in January.
Copy link to clipboard
Copied
It would have to round every possibility. X.0(5-9) to X.1, X.1(5-9) to X.2, X.2(5-9) to X.3, X.3(5-9) to X.4, etc. Then repeat for every possibiliy of X.9(5-9) to X+1.0.
Now add for every X9.0(5-9) to [X=1]0.0 (e.g. 29.96 rounds to 30.0). Even if you did plug in all those GREP expressions I bet the document would run like molasses in January.
By @Scott Falkner
If you want to round up to whole numbers - then yes, it's pointless.
Copy link to clipboard
Copied
In hindsight you're right. Though I have a feeling that future data sheets aren't going to be as clean, so it's good to know it's possible 🙂 Thanks for the solution though!
Copy link to clipboard
Copied
If it's just every similar thing like 10.70% -> 10.7%
where the 0 is removed
Find
\.\d\K0(?=%)
Change to
<leave blank>