Counting occurrences - how to use the cell reference instead of the text string

mkl1

New Member
Joined
May 30, 2012
Messages
14
Office Version
  1. 365
Hi there.
I wish to count occurrences of a text string that is sitting in Column A. I want to count occurrences for around 50 different text strings in that column (i.e. there are 50 rows), for my IPC codes which are in a separate sheet within my workbook.
So I am using the following formula for the row that has the entry "H01M10/0525" in Column A:

=SUM(LEN(Table24[IPC Codes])-LEN(SUBSTITUTE(Table24[IPC Codes],"H01M10/0525","")))/LEN("H01M10/0525")

It works perfectly well, however, I do not want to have to enter the text string from Column A separately for each of the rows - is there a way to tell Excel to use whatever text is in Column A rather than inputting it manually?

Many thanks

MKL
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,249
Office Version
  1. 365
Platform
  1. Windows
It works perfectly well, however, I do not want to have to enter the text string from Column A separately for each of the rows - is there a way to tell Excel to use whatever text is in Column A rather than inputting it manually?
If I am understanding you correctly, then just replace the hard-coded value with the cell that contains the value you are looking for.
For example, if cell A1 contains "H01M10/0525" then just change your formula to:
Excel Formula:
=SUM(LEN(Table24[IPC Codes])-LEN(SUBSTITUTE(Table24[IPC Codes],A1,"")))/LEN(A1)
Then, if you copy that formula down the column, the references of A1 will change to A2, then A3, etc.

So is that what you are looking for?
 
Solution

mkl1

New Member
Joined
May 30, 2012
Messages
14
Office Version
  1. 365
If I am understanding you correctly, then just replace the hard-coded value with the cell that contains the value you are looking for.
For example, if cell A1 contains "H01M10/0525" then just change your formula to:
Excel Formula:
=SUM(LEN(Table24[IPC Codes])-LEN(SUBSTITUTE(Table24[IPC Codes],A1,"")))/LEN(A1)
Then, if you copy that formula down the column, the references of A1 will change to A2, then A3, etc.

So is that what you are looking for?
Hi there Joe,

Thanks - unfortunately this does not work.
 

mkl1

New Member
Joined
May 30, 2012
Messages
14
Office Version
  1. 365
If I am understanding you correctly, then just replace the hard-coded value with the cell that contains the value you are looking for.
For example, if cell A1 contains "H01M10/0525" then just change your formula to:
Excel Formula:
=SUM(LEN(Table24[IPC Codes])-LEN(SUBSTITUTE(Table24[IPC Codes],A1,"")))/LEN(A1)
Then, if you copy that formula down the column, the references of A1 will change to A2, then A3, etc.

So is that what you are looking for?
Hi - yes this did work - I just needed to make the first entry A3 - thanks this is great!
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,249
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
Glad I was able to help.
 

Forum statistics

Threads
1,136,322
Messages
5,675,085
Members
419,549
Latest member
EliteBeat

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
Top