Find a . (period)

T

Todd Huttenstine

I have a variable called "TmpVal" and it can be anything.
It will always have a "." in the value. How do I make it
show the value up to the very first "." going from left to
right?

Thank you
Todd Huttenstine
 
P

pikus

For x = Len(TmpVal) To 1 Step -1
If Mid(TmpVal, x, 1) = "." Then
prd = x
End If
Next x
Cells(1, 1).Value = Left(TmpVal, prd - 1)

- Piku
 
P

pikus

Or...

Do
prd = prd + 1
Loop Until Mid(TmpVal, prd, 1) = "."
Cells(1, 1).Value = Left(TmpVal, prd - 1)

That's more compact... - Piku
 
P

pikus

Cells(1, 1).Value = Left(TmpVal, InStr(TmpVal, ".") - 1)

even better. I'm sad I didn't think about that one. :-(
I just insist on going about things the long way... - Piku
 
T

Tom Ogilvy

since you said left to right, better yet to try using instrrev


Why?

Left to right would be the normal way, so instr should be just fine.
 
Top