Count number of characters in a range excluding spaces

Macro Title:
Worksheet Variable:
Data Variable:
Cell Variable:
Result Variable:
Worksheet Name:
Range Reference:
enter the range 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 variables
Dim ws As Worksheet
Dim Rng As Range
Set ws = Worksheets("Analysis")
Set Rng = ws.Range("B5:B7")
totalchar = 0
'count the total number of characters, excluding spaces, in a range by looping through each cell

For Each Cell In Rng
totalchar = totalchar + Len(Application.WorksheetFunction.Substitute(Cell, " ", ""))
Next

ws.Range("D5") = totalchar

End Sub

Sub Count_number_of_characters_in_a_range_excluding_spaces()
'declare variables

Dim ws As Worksheet
Dim Rng As Range

Set ws = Worksheets("Analysis")
Set Rng = ws.Range("B5:B7")
totalchar = 0
'count the total number of characters, excluding spaces, in a range by looping through each cell

For Each Cell In Rng
totalchar = totalchar + Len(Application.WorksheetFunction.Substitute(Cell, " ", ""))
Next

ws.Range("D5") = totalchar

End Sub

Sub Count_number_of_characters_in_a_range_excluding_spaces()
'declare variables
Dim ws As Worksheet
Dim Rng As Range
Set ws = Worksheets("Analysis")
Set Rng = ws.Range("B5:B7")
totalchar = 0
'count the total number of characters, excluding spaces, in a range by looping through each cell

For Each Cell In Rng
totalchar = totalchar + Len(Application.WorksheetFunction.Substitute(Cell, " ", ""))
Next

ws.Range("D5") = totalchar

End Sub