Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Cells Counting Problem

i know that to count the number of cells that contain any text you ca
use:
=COUNTIF(data,"*")

what if i want to differentiate the data as alphabetic data an
alphanumeric data?
eg. COUNTIF(A1:D4,"*") returns 16 when all cells have data like:
abc125 or abc

How do u differentiate data as alphanumeric (abc125) and alphabethi
(abc) data?? PLs help me

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Excel VBA - Cells Counting Problem

if the length of the numeric part is fixed (say 3 digits)
you can break the text string into the numeric part and
then take the value of it and do a countif(range,"0") on
that

=value(right(cell,3) will give you the value of the 3
digits in the 3 rightmost positions of the cell (assuming
there are 3 digits of course). If the cell has no digits,
the result of the expression wil be zero and not picked up
by the countif.

John


-----Original Message-----
i know that to count the number of cells that contain any

text you can
use:
=COUNTIF(data,"*")

what if i want to differentiate the data as alphabetic

data and
alphanumeric data?
eg. COUNTIF(A1:D4,"*") returns 16 when all cells have

data like:
abc125 or abc

How do u differentiate data as alphanumeric (abc125) and

alphabethic
(abc) data?? PLs help me?


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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Cells Counting Problem

thanks for replying john. But the data i am counting are not fixe
meaning the codes wouldn't work, do u have other solutions?
abc125 can also be xxoo09496 or the data can vary

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel VBA - Cells Counting Problem

Hi Wumin,

To return the number of alpha cells, try the following function:

Function CountAlphas(CountRange As Range) As Long
Dim cell As Range
Dim iCtr As Long

For Each cell In CountRange
If Not IsEmpty(cell) Then
If Not cell.Value Like "*[0-9]*" Then
iCtr = iCtr + 1
End If
End If
Next
CountAlphas = iCtr
End Function


---
Regards,
Norman



"wuming " wrote in message
...
i know that to count the number of cells that contain any text you can
use:
=COUNTIF(data,"*")

what if i want to differentiate the data as alphabetic data and
alphanumeric data?
eg. COUNTIF(A1:D4,"*") returns 16 when all cells have data like:
abc125 or abc

How do u differentiate data as alphanumeric (abc125) and alphabethic
(abc) data?? PLs help me?


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Cells Counting Problem

thanks for the help Norman!

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Cells Counting Problem

sry to bother u guys again but i have a problem:
i need to use the formula to count cells of up to 60k records++
and after using the codes given by Norman, the excel file hange
meaning that the codes cannot work for huge amount of datas. Do u guy
have any other alternatives?

its giving me a headache!!! :

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel VBA - Cells Counting Problem

Hi Wuming,

I called the function from a sub, using a range in excess of 16 million
cells. The only problem I experienced was the execution time.

I called the function from a worksheet cell, passing a range in excess of 1
million cells to the function. Again no problem except execution time.

Finally, using your problem example, I called the function from a worksheet
cell, passing the function a range of 61k cells. The function returned a
value in a fraction of a second.

I am sorry, therefore, that I cannot reproduce your problem.


---
Regards,
Norman

"wuming " wrote in message
...
sry to bother u guys again but i have a problem:
i need to use the formula to count cells of up to 60k records++
and after using the codes given by Norman, the excel file hanged
meaning that the codes cannot work for huge amount of datas. Do u guys
have any other alternatives?

its giving me a headache!!! :(


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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel counting problem where there might be 2 entries for one location? Pheasant Plucker® Excel Discussion (Misc queries) 1 March 9th 10 07:04 PM
Counting all cells with red font in Excel Zakynthos Excel Worksheet Functions 2 April 25th 07 02:46 PM
MS Excel counting alternate cells Frank Lennon Excel Discussion (Misc queries) 1 October 25th 06 12:11 PM
Counting filled cells in excel Alex Wilson Excel Worksheet Functions 5 September 19th 05 11:01 PM
Counting cells in Excel? Kelly Lim Excel Discussion (Misc queries) 25 June 2nd 05 09:37 AM


All times are GMT +1. The time now is 03:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"