Thread: Tough teaser!
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
LiAD LiAD is offline
external usenet poster
 
Posts: 386
Default Tough teaser!

Hi,

Small question - where had you planned on the data and results being for
this to run?

Thanks

"Joel" wrote:

I'm not sure if you comma is a real comma or a Thousand place seperator in a
number. this code may work with some modifications. My idea is to pass the
function two parameters. The first one is the string and the sencond
parameter is a count of which number string you want returned. So the
function will return for the following

37 T 1,91 ET 851

37 for the first number string
1,91 for the 2nd number string
851 for the third number string


Function GetNumber(Target As String, NumCount As Integer) As Variant
Dim Chr As String
Dim Results As String

Count = 0
CharPos = 1
Alpha = True 'used to determin if we are processing letters
Do While Count < NumCount And CharPos <= Len(Target)
Chr = Mid(Target, CharPos, 1)
If IsNumeric(Chr) Or Chr = "'" Or Chr = "." Then
'start new number string
If Alpha = True And IsNumeric(Chr) Then
Alpha = False
Results = Chr
Else
Results = Results & Chr
End If
Else
If Alpha = False Then
Count = Count + 1
End If
Alpha = True
End If
CharPos = CharPos + 1
Loop

If Alpha = False Then
Count = Count + 1
End If
If Count = NumCount Then
GetNumber = Val(Results)
Else
Set GetNumber = Nothing
End If
End Function



"LiAD" wrote:

Afternoon,

Is it possible some-one could help with a formula to look inside a text
string mixed of letters, numbers and symbols to return a number that
corresponds to a certain character.

Example of character strings to investigate -

Condition A - 42 N 8 FILS 0,50 or 55 N 12 F 0,50 (two ways of writing this
input)
I need a way of outputting the value before and the value after the N into
two separate cells, so outputs would be 42 and 8 or 55 and 12.

Condition B - 27
I just need it to return the same value, (27)

Condition E - 1 T.2.65CU801+ 9 F.1.05
I need this to return the value before the F, (9).

Condition C - 1 T 120 CU 552 + 68 N 12 F 0,50
As per condition 1, return only the value before and after the N in two
separate cells. The first part before the + is to be ignored. Result 68 and
12

Condition D - 37 T 1,91 ET 851
I need this to return a zero (0) as there is nothing i need to know from this.

Condition E - 3 N 8 F 0,30 + 3 F 0,30
I need this to return three values; the two either side of the N, (3 and 8)
and the one before the F, (3).

Condition F - 3 N 7 F 0,40 + 1 N 6 F 0,40
Result required - the value either side of the two N's - 3 and 7 and 1 and 6

This can be achieved either with formulas or code - depending on what is the
easiest to follow, change if desired and takes the least space. I will have
200 such lines to digest.

Does anyone have any ideas on how best to achieve these results from one
column of 200 input cells going straight to 1-4 columns of results?

Thanks
LiAD