Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Determining text in a cell

I have built a form used by various people. I woull like to make sure they
input some valid form of data into the cell. Upon execution of the macro, I
would like to check the cell for length of characters or somthing like that.
I have tried to use the somthing like:

Dim EHS as String
Dim MyLen as Integer
range("A1").select
EHS = Selection
MyLen = Len(EHS)

If Mylen <2 then
Some type of message or input box....

When I try this I get a Runtime error 13.

Any suggestions?

ZABU


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Determining text in a cell

"ZABU" ha scritto nel messaggio
...
I have built a form used by various people. I woull like to make sure

they
input some valid form of data into the cell. Upon execution of the macro,

I
would like to check the cell for length of characters or somthing like

that.
I have tried to use the somthing like:

Dim EHS as String
Dim MyLen as Integer
range("A1").select
EHS = Selection
MyLen = Len(EHS)

If Mylen <2 then
Some type of message or input box....

When I try this I get a Runtime error 13.


Hi, ZABU.
Try this:
-----------------------------
.....
Dim EHS As String
Dim no As Boolean
If IsError(Range("K1")) Then
no = True
Else
If Len(Range("K1").Value) < 2 Then
no = True
Else
EHS = Range("K1").Value
End If
End If

If no Then MsgBox ("Not valid")
......
-----------------------------


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Determining text in a cell

Hi ZABU,

I think you may also try to handle Change Event of the worksheet.
The event will be fired if we change the value of one cell in the worksheet
and we then can valid the value in the cell and take the proper action.
e.g.
Private Sub Worksheet_Change(ByVal Target As Range)
Debug.Print Target.Address
If Target.Address = "$A$1" Then
If Len(Target.Text) 5 Then
MsgBox "Not Valid"
Target = vbNullString
End If
End If
End Sub

<quoted
Change Event
See AlsoApplies ToExampleSpecificsOccurs when cells on the worksheet are
changed by the user or by an external link.

Private Sub Worksheet_Change(ByVal Target As Range)
Target The changed range. Can be more than one cell.

Remarks
This event doesn't occur when cells change during a recalculation. Use the
Calculate event to trap a sheet recalculation.

Example
This example changes the color of changed cells to blue.

Private Sub Worksheet_Change(ByVal Target as Range)
Target.Font.ColorIndex = 5
End Sub
</quoted

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Determining text in a cell

Hi ZABU,

Did my suggestion help you?
If you still have any concern on this issue, please feel free to let me
know.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Determining text in a cell

Yes! I put the doed in and everything worked great! Thanks for your
assistance. I still have not had a chance to check teh code for interactive
program monitoring in prior posts.

Thanks Peter.

Regards,

ZABU
""Peter Huang"" wrote in message
...
Hi ZABU,

Did my suggestion help you?
If you still have any concern on this issue, please feel free to let me
know.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.



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
Determining the Cell Address of a VLOOKUP Result in VBA [email protected] Excel Discussion (Misc queries) 3 April 9th 23 12:45 PM
determining the largest value in a sequence of text strings Dave F[_2_] Excel Discussion (Misc queries) 6 January 31st 09 02:33 PM
Determining the text mode from a variety of data types matt3542 Excel Worksheet Functions 17 July 31st 08 08:01 PM
Determining AM or PM in text string Bob Excel Worksheet Functions 8 October 27th 06 12:55 PM
Determining whether selected cell has value or formula? John Wirt Excel Programming 3 July 31st 03 04:19 AM


All times are GMT +1. The time now is 04:24 AM.

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"