LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Extract first four letters from string....

Here is a simple udf that will return the position of the first non-numeric
character in a string. Put it in a standard code module and use it like this
in a cell.

=mid(a1, firstletter(a1), 1)

Public Function FirstLetter(ByVal InputString As String) As Integer
Dim lngCounter As Long
Dim lngStringLength As Long
Dim lngReturnValue As Long

lngReturnValue = -1
lngStringLength = Len(InputString)

For lngCounter = 1 To lngStringLength
If Not IsNumeric(Mid(InputString, lngCounter, 1)) Then
lngReturnValue = lngCounter
Exit For
End If
Next lngCounter

FirstLetter = lngReturnValue
End Function
--
HTH...

Jim Thomlinson


"J.W. Aldridge" wrote:

Hi,

I have a list of codes in column A. I need to extract the first four
letters in every row (disregaurding any numbers or spaces) and paste
them in the same adjacent row in column C.

I also need to do the same for column B to D.

CODE EXTRACTED VALUE
00APPLES APPL
APPLE APPL
APPLE APPL
12313APPL APPL
.....APPLES APPL



Thanx

 
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
Extract Uppercase Letters jnf40 Excel Programming 6 April 10th 08 09:59 PM
Extract Capital Letters jnf40 Excel Discussion (Misc queries) 1 April 10th 08 09:14 PM
Extract two letters bm Excel Discussion (Misc queries) 21 August 11th 07 05:56 PM
Extract letters from a cell Lupe Excel Worksheet Functions 2 November 22nd 06 06:33 PM
How will I do Excel user-defined function to extract letters from string Wavit11 Excel Programming 1 April 30th 04 04:56 AM


All times are GMT +1. The time now is 07:50 AM.

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

About Us

"It's about Microsoft Excel"