Format Cells to Adjust Display Using a Formula

dusty9

New Member
Joined
Oct 2, 2014
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Is it possible to format a cell to have the number input adjusted via formula? What I have for input is numbers 1-40. For 1-20, I want them to show as input, for numbers 21-40, I want them to display as B1, B2, B3, etc.
This is for two rankings merged together, an A group and a B group. I am inputting as 1-40 for conditional formatting and calculation purposes, but would like the display to distinguish the B group.

My thought is "[>20] "B" #-20 ; # " as the custom format, but that is just showing B21-20 where I want B1.

Thank you.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm not aware of any number format that will achieve your aim, however, if you're willing to entertain a VBA solution then try the following code in the worksheet code module of the sheet being used. Save the file as macro-enabled. I've used B2 as the test cell, change to suit.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("B2"), Target) Is Nothing Then
        Application.EnableEvents = False
        If Target > 20 Then Target = "B" & Target - 20
        Application.EnableEvents = True
    End If
End Sub

Example 1 (15 entered)
Book1
ABC
1
215
3
Sheet1
Cells with Data Validation
CellAllowCriteria
B2Whole numberbetween 1 and 40


Example 2 (35 entered)
Book1
ABC
1
2B15
3
Sheet1
Cells with Data Validation
CellAllowCriteria
B2Whole numberbetween 1 and 40
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Couldn't you just use another column?

23 08 28.xlsm
AB
111
222
333
444
555
666
777
888
999
101010
111111
121212
131313
141414
151515
161616
171717
181818
191919
202020
2121B1
2222B2
2323B3
2424B4
2525B5
2626B6
2727B7
2828B8
2929B9
3030B10
3131B11
3232B12
3333B13
3434B14
3535B15
3636B16
3737B17
3838B18
3939B19
4040B20
1-40
Cell Formulas
RangeFormula
B1:B40B1=IF(A1<21,A1,"B"&A1-20)
 
Upvote 0
Thanks, I have 15 rounds of results, and only the best 6 count for scoring, so I am using a conditional formatting to highlight the best 6 for display purposes so viewers can see what rounds are counting towards each score. If I use helper columns producing an alphanumeric text output, I'll lose that formatting. Otherwise that would have been my choice.
Not a make or break thing by any means, just thought it'd be nice to have via formatting on an output sheet. I'll work with the Macro that Kevin provided and see if others accessing the file are comfortable with it.
 
Upvote 0
I have 15 rounds of results, and only the best 6 count for scoring, so I am using a conditional formatting to highlight the best 6 for display purposes so viewers can see what rounds are counting towards each score.
Could you give us some smallish sample data with your current conditional formatting with XL2BB so that we can see just what you have, how it is laid out and what you are trying to achieve?
 
Upvote 0
This is what I have, the events are in 2 regions so not a ton of overlap, but I have it bring in the results from a different sheet, add a small decimal in to avoid ties for taking the top 6. Event 14 and 15 have a few ranking worse than 20th that I'd like to show as B+[cell value -20]:
2023 Standings.xlsx
ABCDEFGHIJKLMNOPQRSTU
2Event 1Event 2Event 3Event 4Event 5Event 6Event 7Event 8Event 9Event 10Event 11Event 12Event 13Event 14Event 15Event 16Event 17
3Date5/136/036/177/157/217/238/209/086/096/107/027/077/088/148/168/258/26
4RankPointsNameFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFin
51640Competitor 111111 11          
62636Competitor 23    NS  191 1111 1
73629Competitor 32  2 4  344   53  
84611Competitor 41344 212      159  
95610Competitor 542214 32      2120  
106587Competitor 651133 63      3013 2
117576Competitor 76656 94          
128546Competitor 87475 116          
139544Competitor 9NS867 88 209 15111930 10
1410516Competitor 1089811 147 1312 171634NS 16
Action Sprint Tour
Cell Formulas
RangeFormula
A5:A14A5=+RANK(B5,$B$5:$B$104,0)
B5:B14B5=IFERROR(INDEX('AST Unsorted'!B:B,MATCH(ROW(A5)-4,'AST Unsorted'!A:A,0)),".")
M5:U14,D5:K14D5=IFERROR(INDEX(Results!$A:$A,MATCH($AE5&D$2&D$3,Results!$B:$B,0))+COLUMN(D2)/10000,IFERROR(INDEX(Results!$A:$A,MATCH($AE5&D$2&D$3,Results!$B:$B,0)),""))
Named Ranges
NameRefers ToCells
Results!_FilterDatabase=Results!$A$1:$H$601D5:K10, M5:M7, N5:U10, D12:K14, N12:U14
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D14:U14Cell Valuetop 6 bottom valuestextNO
D13:U13Cell Valuetop 6 bottom valuestextNO
D12:U12Cell Valuetop 6 bottom valuestextNO
D11:U11Cell Valuetop 6 bottom valuestextNO
D10:U10Cell Valuetop 6 bottom valuestextNO
D9:U9Cell Valuetop 6 bottom valuestextNO
D8:U8Cell Valuetop 6 bottom valuestextNO
D7:U7Cell Valuetop 6 bottom valuestextNO
D6:U6Cell Valuetop 6 bottom valuestextNO
D5:U5Cell Valuetop 6 bottom valuestextNO
 
Upvote 0
Thanks for the XL2BB sample data. Could you set up a helper area elsewhere (I have done it below but it could even be on another worksheet) like this & use this new conditional formatting?
Note that this new CF is applied to the new area but uses the values in the original area.

23 08 29.xlsm
ABCDEFGHIJKLMNOPQRSTU
2Event 1Event 2Event 3Event 4Event 5Event 6Event 7Event 8Event 9Event 10Event 11Event 12Event 13Event 14Event 15Event 16Event 17
3DateMay-136-MarJun-17Jul-15Jul-21Jul-23Aug-209-Aug6-Sep6-Oct7-Feb7-Jul7-AugAug-14Aug-16Aug-25Aug-26
4RankPointsNameFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFin
51640Competitor 11111111
62636Competitor 23NS19111111
73629Competitor 322434453
84611Competitor 41344212159
95610Competitor 542214322120
106587Competitor 6511336330132
117576Competitor 7665694
128546Competitor 87475116
139544Competitor 9NS867882091511193010
1410516Competitor 10898111471312171634NS16
15
21
22Event 1Event 2Event 3Event 4Event 5Event 6Event 7Event 8Event 9Event 10Event 11Event 12Event 13Event 14Event 15Event 16Event 17
23May-13Mar-23Jun-17Jul-15Jul-21Jul-23Aug-20Aug-23Sep-23Oct-23Feb-23Jul-23Aug-23Aug-14Aug-16Aug-25Aug-26
24RankPointsNameFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFinFin
251640Competitor 111111 11          
262636Competitor 23    NS  191 1111 1
273629Competitor 32  2 4  B144   53  
284611Competitor 41344 212      159  
295610Competitor 542214 32      B120  
306587Competitor 651133 63      B1013 2
317576Competitor 76656 94          
328546Competitor 87475 116          
339544Competitor 9NS867 88 209 151119B10 10
3410516Competitor 1089811 147 1312 1716B14NS 16
dusty9
Cell Formulas
RangeFormula
D22:K23,A24:K24,A25:C34,M22:U24D22=D2
M25:U34,D25:K34M25=IF(M5="","",IF(ISNUMBER(M5),IF(M5<21,M5,"B"&M5-20),M5))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M25:U34,D25:K34Expression=AND(ISNUMBER(D5),D5<=SMALL($D5:$U5,6))textNO
 
Upvote 0
Solution
Hmm, the offset formatting looks like it is the way to go. I'm not very good with the formula conditional formats so I probably wouldn't have gotten there on my own. Thank you for this solution!
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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