Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 58
Default Macro syntax to check string length in a cell

I'm trying to find the VB syntax for checking the length of a string in a
cell.
Any takers? I'm stuck.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro syntax to check string length in a cell

mystring = ActiveCell.Value
mylen = Len(mystring)
MsgBox mylen


Gord Dibben MS Excel MVP

On Wed, 1 Nov 2006 12:16:02 -0800, El Bee
wrote:

I'm trying to find the VB syntax for checking the length of a string in a
cell.
Any takers? I'm stuck.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Macro syntax to check string length in a cell

Sub lcheck()
MsgBox (Len(Selection.Value))
End Sub

Select a cell adn run the macro.
--
Gary's Student


"El Bee" wrote:

I'm trying to find the VB syntax for checking the length of a string in a
cell.
Any takers? I'm stuck.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro syntax to check string length in a cell

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



El Bee wrote:

I'm trying to find the VB syntax for checking the length of a string in a
cell.
Any takers? I'm stuck.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
Row Expansion Susan Excel Worksheet Functions 11 February 28th 06 07:15 PM
checking that cells have a value before the workbook will close kcdonaldson Excel Worksheet Functions 8 December 5th 05 04:57 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"