Macro syntax to check string length in a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to find the VB syntax for checking the length of a string in a
cell.
Any takers? I'm stuck.
 
mystring = ActiveCell.Value
mylen = Len(mystring)
MsgBox mylen


Gord Dibben MS Excel MVP
 
if len(worksheets("sheet1").range("a1").value) > 3 then
or
if len(worksheets("sheet1").range("a1").text) > 3 then

..text is what you see in the cell. .value is what the cell actually contains.

===
If you put 3 in a cell, the .value is 3.

But if you format it to show $3.00, then .text is $3.00
 
Back
Top