Count characters vba

brans1982

Active Member
Joined
Mar 25, 2009
Messages
263
Hi,

I'm trying to count the charaters in a range.

I've tried...

Len(Range("B1:B10").Value)

and

Range("B1:B10").Charaters.Count

Any suggestions.

Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Not sure if you can do that in a single line of code. This should work:

Code:
Sub a()
Dim Count
Dim i As Long

For i = 1 To 10
    Count = Count + Len(Cells(i, 2))
Next i

End Sub
 
Upvote 0
Perhaps like this

Code:
kount = 0
For i = 1 To 10
    kount = kount + Len(Range("B" & i).Value)
Next i
 
Upvote 0
Another way:
Code:
Sub x()
    MsgBox Evaluate("sum(len(B1:B10))")
End Sub
 
Upvote 0
How about:

<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Function</SPAN> NumChars(Rng <SPAN style="color:#00007F">As</SPAN> Range) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>   <SPAN style="color:#00007F">Dim</SPAN> C <SPAN style="color:#00007F">As</SPAN> Range<br>   <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> C <SPAN style="color:#00007F">In</SPAN> Rng.Cells<br>      NumChars = NumChars + Len(C.Value)<br>   <SPAN style="color:#00007F">Next</SPAN> C<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Function</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top