+ Reply to Thread
Results 1 to 3 of 3

Counting special characters inside a cell.

Hybrid View

  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    46201
    Posts
    2

    Counting special characters inside a cell.

    Hey all,

    I need to count the number of times a character appears in each cell. The character I need to count is the 'pipe' character. Here it is:

    |

    I'm trying this:

    =LEN(A1)-LEN(SUBSTITUTE(G2,"|",""))

    and this:

    =LEN(B1)-LEN(SUBSTITUTE(SUBSTITUTE(G2,"|",""))

    and neither seems to work.

    Any help is greatly appreciated.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Counting special characters inside a cell.

    RE:
    =LEN(A1)-LEN(SUBSTITUTE(G2,"|",""))
    =LEN(B1)-LEN(SUBSTITUTE(SUBSTITUTE(G2,"|",""))
    Both of your formula are referencing two different cells:
    A1 or B1 in the first LEN calc...then G2 in the second LEN calc.

    Did you intend to reference either A1 or G2 both times, instead:
    Example:
    =LEN(A1)-LEN(SUBSTITUTE(A1,"|",""))
    =LEN(B1)-LEN(SUBSTITUTE(SUBSTITUTE(A1,"|",""))
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    11-18-2008
    Location
    46201
    Posts
    2
    Whoops, thanks for pointing that out!

    I found those examples by Googling, and I didn't pay close enough attention when I copied + pasted into the forum here. All cell references should've read G2, which is my starting point in the workbook.

    Really what I need to do is count the number of times "|" occurs in each cell, then add 1 to that result so that I know the number of items contained in each cell. The "|" is being used to separate different items in a single cell. Unfortunately for what I'm doing, this is a necessity.
    Last edited by devnullish; 11-18-2008 at 05:01 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1