count number of entries in cell

Hi,

I am trying to count the number of entries in a cell. For eg in cel
A15..I have rat,cat,mat,fat....The function should return 4. Is there 
inbuilt function to do that or what would a macro to do that loo
like.

Thanks,
M

--
Message posted from http://www.ExcelForum.com

0
2/18/2004 3:37:26 PM
excel.misc 78881 articles. 5 followers. Follow

12 Replies
464 Views

Similar Articles

[PageSpeed] 55

Hi
are all your entries separatet by a comma. If yes try
=LEN(A15)-LEN(SUBSTITUTE(A15,",",""))+1


--
Regards
Frank Kabel
Frankfurt, Germany

> Hi,
>
> I am trying to count the number of entries in a cell. For eg in cell
> A15..I have rat,cat,mat,fat....The function should return 4. Is there
> a inbuilt function to do that or what would a macro to do that look
> like.
>
> Thanks,
> MK
>
>
> ---
> Message posted from http://www.ExcelForum.com/

0
frank.kabel (11126)
2/18/2004 3:48:44 PM
As long is the format is consistent

=LEN(A13)-LEN(SUBSTITUTE(A13,",",""))+1

-- 

HTH

Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mkk >" <<mkk.11twgc@excelforum-nospam.com> wrote in message
news:mkk.11twgc@excelforum-nospam.com...
> Hi,
>
> I am trying to count the number of entries in a cell. For eg in cell
> A15..I have rat,cat,mat,fat....The function should return 4. Is there a
> inbuilt function to do that or what would a macro to do that look
> like.
>
> Thanks,
> MK
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
bob.phillips1 (6510)
2/18/2004 3:54:18 PM
thanks guys..it works perfectly...just so i understand.. how exactl
does it work? 

thanks 
M

--
Message posted from http://www.ExcelForum.com

0
2/18/2004 6:48:11 PM
It works on the basis that the number of items is equal; to the number of
delimiters (comma) + 1.

What it does is first to count the characters in the cell (=LEN(A1)), all of
them

Then it substitutes all instances of comma with nothing, and counts this
amended version  (LEN(SUBSTITUTE(A13,",",""))) which is all in memory, not a
worksheet cell

It takes the comma-less count from the total count, adds 1, voila, the
number of items.

-- 

HTH

Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mkk >" <<mkk.11u5a9@excelforum-nospam.com> wrote in message
news:mkk.11u5a9@excelforum-nospam.com...
> thanks guys..it works perfectly...just so i understand.. how exactly
> does it work?
>
> thanks
> MK
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
bob.phillips1 (6510)
2/18/2004 6:58:24 PM
ah! thanks!! but theres a catch..i have all these numbers/text being fe
in by other spreadsheets. In a lot of cases these cells are empty bu
do have a formula. If i do this on a blank cell it still return 1

--
Message posted from http://www.ExcelForum.com

0
2/18/2004 8:39:15 PM
I tried using a if but still doesnt work..

=IF(H11<>"",LEN(H11)-LEN(SUBSTITUTE(H11,",",""))+1,LEN(H11)-LEN(SUBSTITUTE(H11,",",""))

--
Message posted from http://www.ExcelForum.com

0
2/18/2004 8:48:32 PM
And the problem is ?<g>

=IF(H1="","",LEN(H1)-LEN(SUBSTITUTE(H1,",",""))+1)

-- 

HTH

Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mkk >" <<mkk.11uauu@excelforum-nospam.com> wrote in message
news:mkk.11uauu@excelforum-nospam.com...
> I tried using a if but still doesnt work..
>
>
=IF(H11<>"",LEN(H11)-LEN(SUBSTITUTE(H11,",",""))+1,LEN(H11)-LEN(SUBSTITUTE(H
11,",","")))
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
bob.phillips1 (6510)
2/18/2004 9:43:56 PM
the problem is that even if the cell contains nothing (except 
formula)...this cell counting formula still returns a 1.

thank

--
Message posted from http://www.ExcelForum.com

0
2/18/2004 10:03:22 PM
I know, I added a grin at the end<g>

And then I gave a solution .

-- 

HTH

Bob Phillips
    ... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mkk >" <<mkk.11uebk@excelforum-nospam.com> wrote in message
news:mkk.11uebk@excelforum-nospam.com...
> the problem is that even if the cell contains nothing (except a
> formula)...this cell counting formula still returns a 1.
>
> thanks
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


0
bob.phillips1 (6510)
2/18/2004 10:29:57 PM
thanks...but that still doesnt work..it still returns 1 in the empt
cells. Is that because I have a formula in that cell?

Thank

--
Message posted from http://www.ExcelForum.com

0
2/19/2004 8:07:20 PM
This formula returned 1 for cells that looked empty (evaluated to "")?

=IF(H1="","",LEN(H1)-LEN(SUBSTITUTE(H1,",",""))+1)

Maybe your formula evaluated to " " (a space character)?

If yes, you can get use this:
=IF(TRIM(H1)="","",LEN(H1)-LEN(SUBSTITUTE(H1,",",""))+1)

But I think I'd take the time to change the original formulas:

If I had something like:
=if(a1="asdf","ok"," ")
I'd change it to:
=if(a1="asdf","ok","")

Those extra spaces are a pain to work with.


"mkk <" wrote:
> 
> thanks...but that still doesnt work..it still returns 1 in the empty
> cells. Is that because I have a formula in that cell?
> 
> Thanks
> 
> ---
> Message posted from http://www.ExcelForum.com/

-- 

Dave Peterson
ec35720@msn.com
0
ec35720 (10082)
2/20/2004 12:58:06 AM
Thanks a lot! that works perfectly! Yeah these invisible blank space
drive me crazy!

Thanks again,

M

--
Message posted from http://www.ExcelForum.com

0
2/20/2004 8:15:15 PM
Reply:

Similar Artilces:

Cell formating in Excel?
Is there a way to have a scroll bar in a single cell? No. -- Best Regards, Luke M "pmarina" <pmarina@discussions.microsoft.com> wrote in message news:5D25B665-B7B8-477D-AAF8-80A347FFA0DD@microsoft.com... > Is there a way to have a scroll bar in a single cell? ...

How to get a long column of numbers to wrap and print on 1 page?
I have a long column of numbers that we add to daily. This column needs to be sorted in ascending order and then printed. I don't know of a way to sort multiple columns together so that is why it is one long column. Is there a way to get it to print as multiple columns across a page so as to not have numerous pages with only 1 column on each? Thanks. take a look here: http://www.mvps.org/dmcritchie/excel/snakecol.htm In article <3880FBB4-BF95-4A82-B98A-519C79BF1A34@microsoft.com>, Sue <Sue@discussions.microsoft.com> wrote: > I have a long column of numbers th...

Excel-how (find/replace) for multifmat cells w/o changing fmat
For a client, i need to be able to find and replace words in cells with 2 formats. But when you replace them,it changes the format of the whole cell, and not just what you changed. Is there any way to work around this without changing the format after all of the find and replaces? Saved from a previous post, but this one has some wordwrap problems fixed: I think you'd have to keep track of each character's font attributes. This works very slowly, but works: Option Explicit Option Compare Text Type myCharacter myChar As String myLen As Long myName As String myFo...

Pivot table and counting.
I have a pivot table that gives me the number of rides done by a van. I can have the pivot table return the number of rides, but what I need is the number vans that participated for a certain day. Example, it is possible to have 27 trips done by 18 vans, how can I count the number of vans and not addup the van number? Any help appreciated. Thank you, Joe Hi Joe We need a bit more information on how your source data table is set up. What information do you have in each column? -- Regards Roger Govier sacredarms <sacredarms@discussions.microsoft.com> wrote: > I have a pi...

Removiing decimals from an excel number
Here is the issue: I have numbers like this one - 10000.01.01.200 I just want the prime number 10000. How can I do that? I tried Ctrl+F and replace but is there a more efficient way? Thanks! =LEFT(A1,FIND(".",A1)-1) -- Gary''s Student - gsnu201001 "Data Analyst" wrote: > Here is the issue: I have numbers like this one - 10000.01.01.200 > > I just want the prime number 10000. How can I do that? I tried Ctrl+F and > replace but is there a more efficient way? > > Thanks! try this =LEFT(A1,FIND(".",A1,1)-1)...

Set RN = Range(Cells(2, 1), Cells(r, 1)) error
What wrong with this. It create error. How can I improve to get rid the error? Set RN = Range(Cells(2, 1), Cells(r, 1)) Thanks Daniel Hi Daniel, Too much missing information - has r been declared and what data type is it and what value does it have. What property of the range are you trying to store in the variable RN? What type of variable is RN and has it been declared. -- Thanks, Shane Devenshire "Daniel" wrote: > What wrong with this. It create error. How can I improve to get rid the > error? > > Set RN = Range(Cells(2, 1), Cells(r, 1)) > &...

Cycle Counting
Hello, I am looking for ideas on how to cycle count serial number tracked items without increasing workload. Our serialized items are barcoded but the problem is the are situated on the pallet incorrectly and the pallet is placed on a third level of a racking system. If we could just cycle count based on item count and not include the serial number it would make it easy. Is this possible in Great Plains. We are running Great Plains 8.0. Any suggestions are greatly aprreciated. Thank You, Brian Morris Database Administrator ...

change highlight color on active cells
How do I change the active highlight color of an active cell. Louis Only though VBA. Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) Static OldCell As Range If Not OldCell Is Nothing Then OldCell.Interior.ColorIndex = xlColorIndexNone End If Target.Interior.ColorIndex = 6 'yellow Set OldCell = Target End Sub This is sheet event code. Right-click on the sheet tab and "View Code". Copy and paste into that module. Chip Pearson has a great add-in named Rowliner.xla that will make the highlighting available for all sheets and workbooks. The code above w...

Count
Hi, I would like to know how which formula I should use to count some codes & to ignore the duplicated codes, for example in column A: Code 1234 4321 4321 1234 1234 3214 Now, I want Excel to count & the result is 3 which are: 1234-4321-3214 Yes I can use PivotTable, but I would like to use a formula because I have to deal with this every day. I appreciate your support. -- MFS22 COUNTIF will do it. =COUNTIF(Rng,Rng), where the criterion is the same as the range: e.g =COUNTIF(A3:A8,A3:A8) HTH Peter "MFS" wrote: > Hi, > I wo...

Formulas don't work in certain cells #3
One formula is: =SUM(C10:C15) another: =SUM(O16/6363) another: =SUM(C19:C36) these same formulas work in the cells right next to these wit different cell references. However, no matter which cell I put th above formulas in, the result is the same - either blank with a dash i the cell or zero. I checked all the cells that the formulas refer t and none has any errors. -Jorda -- kalik24 ----------------------------------------------------------------------- kalik247's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1594 View...

Window's verson numbers
I'm writing an app in C++ using VS.net and I need to do this based on the OS. I can get the OS version number using _osver global variable found in the include STDLIB.H. But I need a list of what version number correspond to what OS so I know what the value in _osver means. Does anyone know where I can find these definitions? Also the major and minor builds might be useful? If this is the wrong newsgroup could you direct me to the right one? Thank Lots, Neil Neil B wrote: >I'm writing an app in C++ using VS.net and I need to do this based on the OS. >I can get the OS ver...

format cells #4
hi. how can i set by default the cell formatting to 'general' or 'number' or even 'text'? i mean i dont want excel to correct let's say: 1.5 to 01.may or 9/12 to 09.dec. is this possible? thanks. (i have some programs which export data to excel and instead of numbers in excel appear dates and i can't set the cell format before the data is exported) -- notrace2004 ------------------------------------------------------------------------ notrace2004's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=34817 View this thread: http://www....

How do I count the # of times a value reoccurs and plot it over ti
I wish to plot a number of errors made by each users and compare it over time. I have a column of user ID's and a column of dates. I want the chart to count the number of times each user ID appears and plot against it's corresponding date. However, each time I try to do this, the chart appears wrong. Any ideas? In article <9595B2A1-8282-4AB3-8511-A6776E108164@microsoft.com>, Stephen@discussions.microsoft.com says... > I wish to plot a number of errors made by each users and compare it over > time. I have a column of user ID's and a column of dates. I want t...

Formatting cells in Excel with Ascending/Descending order
I am trying to insert a drop down asceding/descending arrow in the cell of the excel document. When you click on the arrow which is a small box on the right side of the cell, it will organize all figures/data in that column and you can choose between ascending/descending, or how you want to organize it. Thank you -- Andrew ...

Line count
I am working with a program called Dictaphone. We use Word 2007 in this program. The line count on Dictaphone and the line count in Word 2007 are different even though the Dictaphone text is retrieved from Word 2007. Why would they be different? What is the difference between virutal line count and physical line count? ...

count number of characters in rich edit control
How can i count number of characters in rich edit control 2 If u mean controls of type Rich TextBox control, try RichControl1 RC1; CString Mes=RC.GetText(); int n=Mes.GetLength(); "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i count number of characters in rich edit control 2 EM_GETTEXTLENGTHEX, WM_GETTEXTLENGTH, WM_GETTEXT, EM_STREAM* "Rahul" <Rahul@discussions.microsoft.com> wrote in message news:7743023C-EA83-4ACA-AB67-F1AE7279F1EB@microsoft.com... > How can i co...

Counting sales
I have two different datasets. Each with a common identifier. I need a formula that will reference the identifiers in both datasets and count the number of sales a particular agent made. Example. look up this identifier in the other dataset and then give me the value that is 2 columns over from the identifier in the second dataset. See if this helps: http://contextures.com/xlFunctions02.html -- Biff Microsoft Excel MVP "Dave" <Dave@discussions.microsoft.com> wrote in message news:E7245B37-033F-400E-9CEE-9822BE7CB0F5@microsoft.com... >I have two...

Counting Cells with Conditional Formatting
Is there a way to look at a row of data that is either highlighted yellow or red and to count only the data that is highlighted yellow and give me that number? None of my data is numerical....just one letter data, i.e.: "S" or "U" I just want to count how many of the cells are highlighted yellow in a specific row, if that makes more sense. Here's a UDF (Put in a Standard module) and use it in cell A1, like =CountByColor(A8:H8,6) << where 6 (at present) = Yellow = change to =CountByColor(A8:H8,3) to get the reds HTH Function CountByColor(InRa...

COUNT ? need formula
Hi, I want to track the results of my teams sales performance. I record if it is a sale, no sale, cancelled etc in column M. I thought I'd be able to use the COUNT function/formula to be able to search for all the SALES in column M and place the result in a cell ( column O )but I can't work it out. Any ideas? Damian Hi! Try this: =COUNTIF(M1:M100,"sale") Biff "Diamond Jones" <kwanzaNOSPAM@optusnet.com.au> wrote in message news:43a0e897$0$17704$afc38c87@news.optusnet.com.au... > Hi, > > I want to track the results of my teams sales perf...

How to retrieve value from specific cell value?
Does anyone have any suggestions on how to retrieve value from specific cell value with specific worksheet? I would like to create a if-statement within macro, If specific cell within specific worksheet = 1 then process following code End If Does anyone have any suggestions? Thanks in advance for any suggestions Eric hi If Sheets("sheet1").Range("A1") = 1 Then MsgBox "run code" Else MsgBox "skip code" End If regards FSt1 "Eric" wrote: > Does anyone have any suggestions on how to retrieve value from specific cell &...

telephone number field mask
I have a field I use for telephone numbers. I would like the mask to return data like this : 111 111 1111. What is the formula for this? Any help is appreciated. Mtn244: Thanks much for assistance. I tried your mask with great success. All is good in River City. Thanks again for your help. Frank "mtn244" <mtn244@discussions.microsoft.com> wrote in message news:82895481-BC0D-4FB7-A9A8-1649395C1224@microsoft.com... > Try this input mask: > !999 000 0000;0; > > "Frank" wrote: > >> I have a field I use for telephone numbers. I would lik...

Is it possible to plot discontiguous cells?
Hi, I posted this yesterday in Miscellaneous, but thought it would be a good idea to ask here, too. I have a column which returns data from other columns based on a set of formulas. The result in each cell can be either a number (to plot in a line chart) or a blank and/or "-" sign like so: 5 - - 3 - - - 8 I would like to be able to chart only the numbers which result in this column. The dashes and numbers will not always position in the same manner as the calculations are altered by user input (therefore I cannot merely return the next number a fixed rows down into another colum...

Astrisks out restricted form entry
I have an open form event that triggers a restricted form in vba. strPasswd = InputBox("Enter Password", "Restricted Form") The form is only code, not an actual form. How do I astrisks out the password that is entered? You can't. The InputBox doesn't have that capability. You can create a form that has a text box with the appropriate Password Input Mask, and have it pass the value back to your originating form. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Ryan Tisserand" <RyanTisserand@discussions.microsoft...

Changed Cell Address
I am using the Sub shown below. Question: How do I determine the address of the changed cell? Private Sub Worksheet_Change(ByVal Target As Range) Dim WatchRange As Range Dim IntersectRange As Range Set WatchRange = Range("E1:E31") Set IntersectRange = Intersect(Target, WatchRange) If IntersectRange Is Nothing Then 'MsgBox "Changes occured outside of range" Else 'MsgBox "You modified the selected range of cells" Application.Run "Test.xls!Time_Stamp" End If End Sub Hi Richard maybe target.address Cheers JulieD "Richard"...

Count Function
I am creating a report for the number of pupils being collected at a certain collection time e.g. 14:00hr and 15:00hrs using the formula =Count([Child Last Name]) in the collection time footer However when i try to count the overall number of pupils in the footer using the same formula, 'Error' appears on screen? Thanks There are potentially a dozen footer sections in a report. Which one is giving you a problem? What is the name of the control? What is the exact formula? -- Duane Hookom Microsoft Access MVP "ELo" wrote: > I am creating a r...