Find a . (period)

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
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
 
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
 
Or...

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

That's more compact... - Piku
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

LastName, FirstName format 2
Deleting blanks from the end of values in cells 4
Function variables 7
Trim "\" Value 7
Static Variable 7
Listbox 8
Selecting a listbox item event 3
Listbox Selection 1

Back
Top