Is there a way to use a number from a table heading in a formula?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,691
Office Version
  1. 365
Platform
  1. Windows
This table shows some usage statistics relative to how often different letters occur in normal text. The last three columns show how many of each letter a typist will see in an hour of typing at various typing speeds (wmp). As it is, the wpm are hard coded in each cell formula (H7:J13). But that means that if I want to change the wpm, I have to edit the heading and each formula. This is tedious and error prone. Is there any way that I can extract just the number in each heading and use it in the formulas so that I can change the number in the headings and have all of the formulas change, too?

Typing Tutor Adaptive Learning Algorithm.xlsm
BCDEFGHIJ
2eRelative key3,000Characters/page
312.30%Relative key frequency
4
5R/CCDEFGHIJ
66LetterFreqCommentsRel Freq vs "e"#/PageChars/Hour at 20 wpmChars/Hour at 30 wpmChars/Hour at 40 wpm
77e12.30%Easy key1.000036973811071476
88m2.50%Difficult key0.203475150225300
99f2.21%Home key0.179866133199265
1010p1.92%Difficult key0.156058115173230
1111j0.15%Home key0.0122591418
1212q0.10%Difficult key0.008236912
1313z0.08%Difficult key0.006625710
Relative Key Freq
Cell Formulas
RangeFormula
C3C3=XLOOKUP(RefLetter,TblLetters[Letter],TblLetters[Freq])
C5:J5C5=col()
F7:F13F7=[@Freq]/RefLetterFreq
G7:G13G7=CharsPerPage*[@Freq]
H7:H13H7=20*60*5*[@Freq]
I7:I13I7=30*60*5*[@Freq]
J7:J13J7=40*60*5*[@Freq]
B6:B13B6=ROW()
D7:D13D7=XLOOKUP([@Letter],TblLetters[Letter],TblLetters[Freq])
Named Ranges
NameRefers ToCells
A2Z=Globals!$B$9:$B$34D7:D13, C3
A2ZFreq=Globals!$C$9:$C$34D7:D13, C3
'Relative Key Freq'!CharsPerPage='Relative Key Freq'!$F$2G7:G13
LetterFreqTable=Globals!$B$9:$D$34D7:D13, C3
'Relative Key Freq'!RefLetter='Relative Key Freq'!$C$2C3
'Relative Key Freq'!RefLetterFreq='Relative Key Freq'!$C$3F7:F13


Before tables, I was able to put just the number in the heading and then format them to add the text, like this:

Typing Tutor Adaptive Learning Algorithm.xlsm
DEFGH
6LetterFreq20 wpm30 wpm40 wpm
7e12.30%73811071476
8m2.50%150225300
9f2.21%133199265
10p1.92%115173230
11j0.15%91418
12q0.10%6912
13z0.08%5710
OLD >>>
Cell Formulas
RangeFormula
E7:E13E7=XLOOKUP('OLD >>>'!$D7,TblLetters[Letter],TblLetters[Freq])
F7:H13F7=F$6*60*5*$E7
Named Ranges
NameRefers ToCells
A2Z=Globals!$B$9:$B$34E7:E13
A2ZFreq=Globals!$C$9:$C$34E7:E13
LetterFreqTable=Globals!$B$9:$D$34E7:E13


But that doesn't work with tables.

Is there another way?

Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You could do a series of helper cells in H4:J4 that extracted the number from the text in H5:J5, and then reference those in the formula.

Book3
HIJ
4203040
5Chars/Hour at 20 wpmChars/Hour at 30 wpmChars/Hour at 40 wpm
6
Sheet1
Cell Formulas
RangeFormula
H4:J4H4=SUBSTITUTE(SUBSTITUTE(H5,"Chars/Hour at ","")," wpm","")
 
Upvote 0
You could do a series of helper cells in H4:J4 that extracted the number from the text in H5:J5, and then reference those in the formula.

Book3
HIJ
4203040
5Chars/Hour at 20 wpmChars/Hour at 30 wpmChars/Hour at 40 wpm
6
Sheet1
Cell Formulas
RangeFormula
H4:J4H4=SUBSTITUTE(SUBSTITUTE(H5,"Chars/Hour at ","")," wpm","")
That's a possibility. I should have mentioned that did try something like that. I would replace "H5" in your expression with a table reference
Code:
tablename[[#Headers],[Chars/Hour at 40 wpm]]
.
But it has a couple of problems:
  1. Being outside the table, it won't move if I move any of the table columns.
  2. If I am going to have a helper cell putside the table, I'd really prefer to make the changes there and have both the formulas and the headings change to match.
Thanks
 
Upvote 0
That's a possibility. I should have mentioned that did try something like that. I would replace "H5" in your expression with a table reference
Code:
tablename[[#Headers],[Chars/Hour at 40 wpm]]
.
But it has a couple of problems:
  1. Being outside the table, it won't move if I move any of the table columns.
  2. If I am going to have a helper cell putside the table, I'd really prefer to make the changes there and have both the formulas and the headings change to match.
Thanks
1. If you reference the table columns by name rather than H5, it won't matter where they are if you moved them. You can Name the helper cells to make them less sensitive to position (e.g. Helper1 rather than H4).
2. As far as I know, there is no way to put a formula into a table header. But you could call them something generic like "Chars/hour at X wpm", and then have a cell say "X = 20" outside the table.
2a. Except that if you have values X/Y/Z in named cells, and a table with a "Header" column, you can have Power Query do a Pivot Columns to yield column names based on cell values.

Book4
ABCD
1X20
2Y30
3Z40
4
5KeyHeader valueHeadervalue
6eXChars/Hour at 20 wpm738
7eYChars/Hour at 30 wpm1107
8eZChars/Hour at 40 wpm1476
9
10KeyChars/Hour at 20 wpmChars/Hour at 30 wpmChars/Hour at 40 wpm
11e73811071476
Sheet1
Cell Formulas
RangeFormula
C6:C8C6="Chars/Hour at "&INDIRECT([@[Header value]])&" wpm"
 
Upvote 0
It would be nice if the table nomenclature had a symbol for "this column" like it does for "this row" (@), but no such luck. There are some options though. Consider:

Book1 (version 1).xlsb
ABCDEFGHIJ
1
2eRelative key3000Characters/page
312.30%Relative key frequency
4
5
6LetterFreqCommentsRel Freq vs "e"#/PageChars/Hour at 20 wpmChars/Hour at 35 wpmChars/Hour at 45 wpm
7e12.30%Easy key1.00003697381291.51660.5
8m2.50%Difficult key0.203375150262.5337.5
9f2.21%Home key0.179766.3132.6232.05298.35
10p1.92%Difficult key0.156157.6115.2201.6259.2
11j0.15%Home key0.01224.5915.7520.25
12q0.10%Difficult key0.00813610.513.5
13z0.08%Difficult key0.00652.44.88.410.8
Sheet4
Cell Formulas
RangeFormula
C3C3=XLOOKUP(RefLetter,TblLetters[Letter],TblLetters[Freq])
F7:F13F7=[@Freq]/XLOOKUP($C$2,[Letter],[Freq],0)
G7:G13G7=CharsPerPage*[@Freq]
H7:H13H7=MID(INDEX(TblLetters[#Headers],COLUMN([@[Chars/Hour at 20 wpm]])-COLUMN([@Letter])+1),15,2)*60*5*[@Freq]
I7:I13I7=MID((TblLetters[#Headers] OFFSET([Chars/Hour at 35 wpm],-1,0)),15,2)*60*5*[@Freq]
J7:J13J7=45*60*5*[@Freq]
Named Ranges
NameRefers ToCells
CharsPerPage=Sheet4!$F$2G7:G13
RefLetter=Sheet4!$C$2C3, F7:F13


The 20 wpm column has a formula where it figures out the proper column by looking at the column of the current cell, subtracting the column of the first column in the table, and using that as an index into the headers. Then I used MID to get the value out of the heading. So if you change the heading to "Chars/Hour at 25 wpm", the formulas in the column will all adapt.

The 35 wpm column has a shorter formula that does the same thing. But it uses the volatile OFFSET (usually not an issue), and the intersection operator which is rarely used. It works the same as the previous formula.

For both of these I tried using some fancy custom formatting in the cells to avoid the MID, but it seems that table headings don't like that.

The final formula for the 45 wpm column is basically the same as what you had originally. So it's not quite as simple as changing the heading only, but all you have to do is change the heading and the first formula in the column only. All the rest of the formulas will change automatically. So you have to change 2 cells instead of 1, not quite as simple, but you avoid these awkward formulas that reference the headings.
 
Upvote 0
1. If you reference the table columns by name rather than H5, it won't matter where they are if you moved them. You can Name the helper cells to make them less sensitive to position (e.g. Helper1 rather than H4).
2. As far as I know, there is no way to put a formula into a table header. But you could call them something generic like "Chars/hour at X wpm", and then have a cell say "X = 20" outside the table.
2a. Except that if you have values X/Y/Z in named cells, and a table with a "Header" column, you can have Power Query do a Pivot Columns to yield column names based on cell values.
By the way, you can't tell by the xl2bb copy, but I named B1 as "X" (and B2 as "Y" etc.), for reference in the INDIRECT formula.
 
Upvote 0
1. If you reference the table columns by name rather than H5, it won't matter where they are if you moved them. You can Name the helper cells to make them less sensitive to position (e.g. Helper1 rather than H4).
2. As far as I know, there is no way to put a formula into a table header. But you could call them something generic like "Chars/hour at X wpm", and then have a cell say "X = 20" outside the table.
2a. Except that if you have values X/Y/Z in named cells, and a table with a "Header" column, you can have Power Query do a Pivot Columns to yield column names based on cell values.

Book4
ABCD
1X20
2Y30
3Z40
4
5KeyHeader valueHeadervalue
6eXChars/Hour at 20 wpm738
7eYChars/Hour at 30 wpm1107
8eZChars/Hour at 40 wpm1476
9
10KeyChars/Hour at 20 wpmChars/Hour at 30 wpmChars/Hour at 40 wpm
11e73811071476
Sheet1
Cell Formulas
RangeFormula
C6:C8C6="Chars/Hour at "&INDIRECT([@[Header value]])&" wpm"
Ok, I'll give that a try. Thanks
 
Upvote 0
It would be nice if the table nomenclature had a symbol for "this column" like it does for "this row" (@), but no such luck. There are some options though. Consider:
Wow. That's some interesting things to play with. That should keep me out of trouble for a bit. Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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