how to count Data Carrecter without space

B

Brendan Reynolds

character counts said:
Data character count function


If I understand correctly, that you want to count the number of characters
in a string ignoring any spaces in the string, then the following function
should do it ...

Public Function CountIgnoringSpaces(ByVal InputString As String) As Long
CountIgnoringSpaces = Len(Replace(InputString, " ", vbNullString))
End Function

Example of use, in the Immediate window ...

? countignoringspaces("abc def")
6
 
Top