View Full Version : find just one digit of number but it should find whole number
saban
08-29-2006, 01:53 AM
I have text which looks like this:
50% - 74% 1 10 100 0
Now I am searching for 50% - 74% and when this is found move cursor to the end of this word and then search for any digit ^# and when 1 is found go to next one which I need (10) but the problem is it finds just first number which is 1 but I need to find whole number which is 10
Any ideas how can this be done
Thnx
Not easy to understand what you really need. Maybe Split function could be useful.Sub UseSplitFunction()
myval = Split("10 100")
MsgBox myval(0)
MsgBox myval(1)
End Sub
saban
08-29-2006, 03:29 AM
Those numbers 100 and 10 can be different they are not always 10 and 100 I need to find whole number for instance if I try find method, and the caharacter that I am looking for is any digit (^#) then if number 10 is the number it should find, it finds only number 1 and it doesnt consider 0 because I guess it searches only 1 digit at the time but I need it to find me whole number which is 10 not just 1
Pasquale
08-29-2006, 04:23 AM
Not easy to understand what you really need.
Use Find:
[0-9]{1;3}
chek wildcards
pasquale
saban
08-29-2006, 04:36 AM
I just need to find number in corresponding row
And this number can be of any value
Sub StringToPass()
Call findnumbers("50% - 74% 1 10 100 0")
End Sub
Sub findnumbers(mystring)
Dim findnumbers
If Mid(mystring, 1, 9) = "50% - 74%" Then
findnumbers = Split(mystring)
For i = 0 To UBound(findnumbers)
If IsNumeric(findnumbers(i)) Then MsgBox findnumbers(i)
Next i
End If
End Sub
saban
08-29-2006, 06:02 AM
I'll try and let u know
saban
08-29-2006, 06:22 AM
Do you maybe know why if it I find 9.33 and passed this value into variable it gives me 933 instead of 9.33
I don't get that error
http://www.vbaexpress.com/forum/C:\Documents and Settings\ABOFFI\Desktop\noerror.jpg
saban
08-29-2006, 07:36 AM
It is ok I figured it out It shouldnt be . but , to work corectly
Thnx for your help
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.