How to remove decimal numbers out of only 100%

edge37

Board Regular
Joined
Sep 1, 2016
Messages
87
Office Version
  1. 2021
Platform
  1. Windows
Greeting! I have this question: I have a cell in which I need to show averages of grades, that includes 2 decimals, as percents, but I would like to format the cell for, when I have a 100% average, all decimals are removed, the rest of numbers will keep their decimals, EXCEPT 100%, which I want it to show without any decimals..
I'm using a VBA code and a formula for showing the averages in just one cell when I click a student's name:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Range("AM9").Value = ActiveCell.Value
End Sub
Code:
=CELL("address")
In Format Cell>Number>Custom, I use 0.00%;;""
In the cell I use the formula:
Code:
=IFERROR((VLOOKUP($AM$9,$B$9:$Z$33,19,FALSE)/100),0)
Is this possible? Thanks for your help

Please advice if I have to send anything else to fully explain myself. The image illustrates the problem.
 

Attachments

  • Screenshot_21.jpg
    Screenshot_21.jpg
    129.3 KB · Views: 20
Try this. If it doesn't work we'll have to go another route.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("AM9").Value = ActiveCell.Value
If ActiveSheet.Range("AM9") = 1 Then
        ActiveSheet.Range("AM9").NumberFormat = "0%"
End If
End Sub
 
Upvote 1

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I would like to format the cell for, when I have a 100% average, all decimals are removed, the rest of numbers will keep their decimals, EXCEPT 100%, which I want it to show without any decimals..
Try the following:
Format the cells with the %'s as percentage/no decimal places (which will show your 100% without the decimals)
Add conditional formatting to those cells:
Conditional Formatting / New Rule / Use a formula to determine which cells to format
Enter the formula: =MOD(C1,1)>0 (where C1 is the cell with the %)
Set the format to percentage - 2 decimal places
This is what you get:
Book1
C
1100%
299.80%
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:C2Expression=MOD(C1,1)>0textNO
 
Upvote 1
Solution
Or even simpler, make the format for your cells of interest percentage - 2 decimal places - and your conditional formatting formula = if cell equals 100% then no decimal places; like this:
Book1
C
1100%
299.80%
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:C2Expression=C1=1textNO
 
Upvote 0
PRUEBA 2024.xlsm
AM
140.0%
10A (1)
Cell Formulas
RangeFormula
AM14AM14=IFERROR((VLOOKUP($AM$9,$B$9:$Z$33,19,FALSE)/100),0)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AM14Expression=AM14=100textNO

Try this. If it doesn't work we'll have to go another route.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("AM9").Value = ActiveCell.Value
If ActiveSheet.Range("AM9") = 1 Then
        ActiveSheet.Range("AM9").NumberFormat = "0%"
End If
End Sub
Thank youSkybot, it works great. Thank you again, my friend!
 
Upvote 0
Try the following:
Format the cells with the %'s as percentage/no decimal places (which will show your 100% without the decimals)
Add conditional formatting to those cells:
Conditional Formatting / New Rule / Use a formula to determine which cells to format
Enter the formula: =MOD(C1,1)>0 (where C1 is the cell with the %)
Set the format to percentage - 2 decimal places
This is what you get:
Book1
C
1100%
299.80%
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:C2Expression=MOD(C1,1)>0textNO
Thank you kevin9999, It worked wonderful. Thank you for your kindness, mate.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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