Count number of characters in a range excluding spaces
Macro Title:
|
Worksheet Variable:
|
Worksheet Name:
|
First Row Number:
the first row from which you want to count the number of characters |
Last Row Number:
the last row from which you want to count the number of characters |
Column Reference:
column from which you want to count the number of characters |
Output Cell:
|
First Comment:
' |
Second Comment:
' |
Sub Count_number_of_characters_in_a_range_excluding_spaces()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
totalchar = 0
'count the total number of characters, excluding spaces, in a range by looping through each cell
For x = 5 To 7
totalchar = totalchar + Len(Application.WorksheetFunction.Substitute(Range("B" & x), " ", ""))
Next x
ws.Range("D5") = totalchar
End Sub
Sub Count_number_of_characters_in_a_range_excluding_spaces()
'declare a variable
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
totalchar = 0
'count the total number of characters, excluding spaces, in a range by looping through each cell
For x = 5 To 7
totalchar = totalchar + Len(Application.WorksheetFunction.Substitute(Range("B" & x), " ", ""))
Next x
ws.Range("D5") = totalchar
End Sub