Is there a way to put a variable in a custom format?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,535
Office Version
  1. 365
Platform
  1. Windows
Is there any way that I can put a variable in a custom format?

In this table, I would like to be able to calculate in H5, highlighted in yellow, the value in G5, next to it. I can't do that because of the way I generated the results in the rest of Column H, resulting in a non-numeric value. But if I could put the "/ 7" in the custom format, where the "7" is a variable, then the value would remain numeric.

Book1
BCDEFGH
5-3=0-3-11%+3+3???
6EventsHitsMissesTries%Rank %Rank %
7742667%44 / 7
8672978%11 / 7
9542667%44 / 7
10453863%66 / 7
11352771%22 / 7
12242667%44 / 7
13134743%77 / 7
140
Sheet1
Cell Formulas
RangeFormula
C5:G5C5=OFFSET(C6,1,0)-OFFSET(C6,2,0)
E7:E13E7=C7+D7
F7:F13F7=C7/E7
G7:G13G7=RANK.AVG(F7,OFFSET(F$6,1,0):OFFSET(F$14,-1,0),0)
H7:H13H7=RANK.AVG(F7,OFFSET(F$6,1,0):OFFSET(F$14,-1,0),0) & " / " & OFFSET($B$6,1,0)
B7:B13B7=OFFSET(B7,1,0)+1

Thanks
 

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
Hi JenniferMurphy,

I don't see how H5 could be numeric if it is two number on either side of "/". It would need to be text, like the rest of column H.
Something like =$G$5&" / "&$B$7
 
Upvote 0
Hi JenniferMurphy,

I don't see how H5 could be numeric if it is two number on either side of "/". It would need to be text, like the rest of column H.
Something like =$G$5&" / "&$B$7
If the " / 7" is generated in the cell, as in H7, it would be text. But if it is generated by a custom format, as in I7, then it is a number and the formula in I5 works. The formulas in G7 & I7 are identical. It's just the formatting that's different.

Book1
BCDEFGHI
5-3=0-3-11%+3???+3
6EventsHitsMissesTries%Rank %Rank %Rank %
7742667%44 / 74 / 7
8672978%11 / 71 / 7
9542667%44 / 74 / 7
10453863%66 / 76 / 7
11352771%22 / 72 / 7
12242667%44 / 74 / 7
13134743%77 / 77 / 7
140
Sheet1
Cell Formulas
RangeFormula
C5:G5,I5C5=OFFSET(C6,1,0)-OFFSET(C6,2,0)
E7:E13E7=C7+D7
F7:F13F7=C7/E7
G7:G13,I7:I13G7=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0)
H7:H13H7=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0) & " / " & OFFSET($B$6,1,0)
B7:B13B7=OFFSET(B7,1,0)+1

Is that clearer?
 
Upvote 0
Then How result should be different at H5 with G5 or I5, Because data at that cells is same?
The formulas in G7:G13 and I7:I13 are identical and so is the data. The formulas in G5 & I5 are also identical.

The first part of the formulas in H7:H13 are the same, too, but then they have a second part to add the " / 7". In this version, I put the formula in G5 into H5, but since it is acting on different data in H7, it gets a different result. I thought it would get a #Value error or something, but apparently, it is doing some calculation. I have no idea how it got "90".

I am asking if there is a way to put the value of a cell or variable in a custom format expression. Maybe something like:

0 "/" =$B$7

Here's the new version. Row 5 shows the changes in the top row (7) compafred to the following (previous) row (8).

Book1
BCDEFGHI
5Changes→-3=0-3-11%+390+3
6EventsHitsMissesTries%RankRankRank
7742667%44 / 74 / 7
8672978%11 / 71 / 7
9542667%44 / 74 / 7
10453863%66 / 76 / 7
11352771%22 / 72 / 7
12242667%44 / 74 / 7
13134743%77 / 77 / 7
140
Sheet1
Cell Formulas
RangeFormula
C5:I5C5=OFFSET(C6,1,0)-OFFSET(C6,2,0)
E7:E13E7=C7+D7
F7:F13F7=C7/E7
G7:G13,I7:I13G7=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0)
H7:H13H7=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0) & " / " & OFFSET($B$6,1,0)
B7:B13B7=OFFSET(B7,1,0)+1


I checked several places about custom formatting codes. None of them mention variables or cell values, so I assume it's not possible. I can't think of any other way to do what I want to do.
 
Upvote 0
Why you don't Use Fraction for Number format with this formula at H Column:
Excel Formula:
=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0) /  OFFSET($B$6,1,0)
 
Upvote 0
Why you don't Use Fraction for Number format with this formula at H Column:
Excel Formula:
=RANK.AVG($F7,OFFSET($F$6,1,0):OFFSET($F$14,-1,0),0) /  OFFSET($B$6,1,0)
I do not want a fraction in H7:H13 or I7:I13. I want the ranks (integers). I just want them to look like fractions, but not be fractions.

I don't think we are talking about the same thing. Let's let it go.

Thanks
 
Upvote 0
What about This formula for H5:
Excel Formula:
=(LEFT(OFFSET(H6,1,0),FIND("/",OFFSET(H6,1,0))-1)-LEFT(OFFSET(H6,2,0),FIND("/",OFFSET(H6,2,0))-1))/OFFSET($B$6,1,0)

Or
Excel Formula:
=(LEFT(OFFSET(H6,1,0),FIND("/",OFFSET(H6,1,0))-1)-LEFT(OFFSET(H6,2,0),FIND("/",OFFSET(H6,2,0))-1))
 
Upvote 0
Solution

Forum statistics

Threads
1,215,379
Messages
6,124,607
Members
449,174
Latest member
ExcelfromGermany

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