View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default How can I break down text in letters using VBA

Hi Berend,

This will trap the input and process each letter. You will need to fill out
the action to be taken

Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
For i = 1 To Len(.Value)
Select Case LCase(Mid(.Value, i, 1))
Case "a": 'handle a
Case "b": 'handle b
Case "c": 'handle c
'etc.
End Select
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Berend Botje " wrote in
message ...
Hi,

I have a Excel sheet in which text is to be typed by the user. The text
must be broken down in single letters, which the program recognises.

For example:

User types: Fox

Program:
1: Take first letter
2: Check what letter it is
3: Use letter in script (for example a if then statement)
4: Take next letter
5: Repeat steps 2 to 5 untill all text is analysed

Can anyone tell me how to do this? The breaking down of the text, that
is.....

Thanks beforehand,

Berend Botje


---
Message posted from http://www.ExcelForum.com/