Compile Error

G

Guest

Running the below sub caused a compile error: Variable not defined.

The "Cell ref =" portion of the fourth line is highlighted.

What would the correction be?

Thanks, Phil

Sub CountCharacters()

Dim StrinLen As Integer
Dim EmptySpaces As Integer
Dim I As Integer

CellRef = Trim(ActiveCell.Value)

StrinLen = Len(ActiveCell.Value)
For I = 1 To Len(ActiveCell.Value)
If Mid(CellRef, I, 1) = " " Then EmptySpaces = EmptySpaces + 1
Next
MsgBox "String Lengh: " & StrinLen & Chr(10) & "Empty Spaces: " & EmptySpaces
Dim StrinLen As Integer
End Sub
 
T

Tom Ogilvy

Dim StrinLen As Integer
Dim EmptySpaces As Integer
Dim I As Integer
Dim CellRef as Variant
 
G

Guest

Thanks, Tom - works great.

Tom, if you have time, could you look at my post of 6/6 concerning the
hyperlink - trying to put some polish on an application.

Thanks, Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top