Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
joeboe
 
Posts: n/a
Default Iterating through string in a cell


I have an application where i would like to iterate through a cell and
separate integers from text values. I want to take the text values and
find out if they are all the same. In addition, I want to ignore the
text value "X"...

For example:

1bb should just return "b" - since it is all b's and numbers.
x2uu should return "u" - it meets the same criteria as above and x
should be ignored.
2 or x2 would return something like "numeric"
2uubb would return something like "multiples"

Does anyone have any ideas if this is possible in Excel? I would
prefer a formula, but a macro would be ok too. Please help. Thanks so
much!


--
joeboe
------------------------------------------------------------------------
joeboe's Profile: http://www.excelforum.com/member.php...o&userid=27900
View this thread: http://www.excelforum.com/showthread...hreadid=474004

  #2   Report Post  
Stefi
 
Posts: n/a
Default

Hi Joeboe,

I can't imagine such a formula, but here you are a function:


Public Function joeboe(inputstring) As String
Dim i As Long
Dim ByteStr As String, ResultStr As String, FirstLetter As String
Dim NumByte As Boolean
ResultStr = ""
FirstLetter = ""
For i = 1 To Len(inputstring)
ByteStr = Mid(inputstring, i, 1)
NumByte = IsNumeric(ByteStr)
If ByteStr < "x" Then
If FirstLetter = "" And Not IsNumeric(ByteStr) Then
FirstLetter = ByteStr
ResultStr = ByteStr
Else
If ByteStr = FirstLetter Then
ResultStr = ByteStr
Else
If Not IsNumeric(ByteStr) Then
ResultStr = "Multiples"
Exit For
End If
End If
End If
End If
Next i
If ResultStr = "" Then
If NumByte Then ResultStr = "Numeric"
End If
joeboe = ResultStr
End Function

Sorry if you find cases which the function returns wrong answer for.

Regards,
Stefi

€˛joeboe€¯ ezt Ć*rta:


I have an application where i would like to iterate through a cell and
separate integers from text values. I want to take the text values and
find out if they are all the same. In addition, I want to ignore the
text value "X"...

For example:

1bb should just return "b" - since it is all b's and numbers.
x2uu should return "u" - it meets the same criteria as above and x
should be ignored.
2 or x2 would return something like "numeric"
2uubb would return something like "multiples"

Does anyone have any ideas if this is possible in Excel? I would
prefer a formula, but a macro would be ok too. Please help. Thanks so
much!


--
joeboe
------------------------------------------------------------------------
joeboe's Profile: http://www.excelforum.com/member.php...o&userid=27900
View this thread: http://www.excelforum.com/showthread...hreadid=474004


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
how do I convert text string into a cell reference Dave Davis Excel Discussion (Misc queries) 4 May 18th 23 11:48 AM
dynamic cell reference within a text string gvm Excel Worksheet Functions 4 July 25th 05 02:40 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
Numeric cell but shows as string? Brett Excel Worksheet Functions 9 March 24th 05 11:56 AM
Need to find the right-most cell value in a string of cells -dc- Excel Worksheet Functions 2 March 8th 05 07:28 PM


All times are GMT +1. The time now is 11:01 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"