Count using VB

F

Frank Kabel

Hi
not quite sure but maybe
sub foo()
dim svalue as string
dim counter
svalue = "x,y,z"
counter = len(svalue) - len(replace(svalue,",","")) +1
msgbox counter
end sub
 
B

Bob Phillips

or maybe

Msgbox worksheetfunction.counta(Range("A1:H1"))

--

HTH

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

Frank Kabel said:
Hi
not quite sure but maybe
sub foo()
dim svalue as string
dim counter
svalue = "x,y,z"
counter = len(svalue) - len(replace(svalue,",","")) +1
msgbox counter
end sub
 
V

vedrah

thanks.

but it gets more complicated...
I have a series of text many x's , many y's and many z's.
So how do I count only the x's, y's and z's?

help......
 
F

Frank Kabel

Hi
you may first explain how you have stored these values?
- different cells
- in a single cell separated by comas
 
V

vedrah

Hi Frank,

The data is arranged as follows:

x a
x b
x c
x d
y e
y f
y g
z h
z i
z j
z k
z l


how do i count items in column A.

hope u can help.

vedra
 
Top