[COLOR="Blue"]Function[/COLOR] NonZero(Str [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]String[/COLOR]) [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Integer[/COLOR]
[COLOR="Blue"]With[/COLOR] CreateObject("VBScript.RegExp")
.Pattern = "[1-9]"
NonZero = .Execute(Str)(0).FirstIndex + 1
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]With[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Function[/COLOR]
I like to get the position of first non-zero number out of a data range like this:
0 0 0 0 5 4 0 6 0
I am after result of 5 through any formula. Please help!
Thanks, Guys. You are geniuses! I have tried all suggested methods. Apart from Aladin's solution, others all work well. Don't know why, with Aladin's solution, there is always #value error. Anyway, thank you all! This is my first post in this forum. So far so good. Will keep coming back...
Thanks, Aladin. It works now.