ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find a . (period) (https://www.excelbanter.com/excel-programming/298726-find-period.html)

Todd huttenstine

Find a . (period)
 
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

pikus

Find a . (period)
 
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

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

Find a . (period)
 
Have a look in vba help index for instr

--
Don Guillett
SalesAid Software

"Todd Huttenstine" wrote in message
...
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




pikus

Find a . (period)
 
Or...

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

That's more compact... - Piku

--
Message posted from http://www.ExcelForum.com


pikus

Find a . (period)
 
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

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

Find a . (period)
 
since you said left to right, better yet to try using instrrev

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Have a look in vba help index for instr

--
Don Guillett
SalesAid Software

"Todd Huttenstine" wrote in message
...
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






Tom Ogilvy

Find a . (period)
 
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.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
since you said left to right, better yet to try using instrrev

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Have a look in vba help index for instr

--
Don Guillett
SalesAid Software

"Todd Huttenstine" wrote in

message
...
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








Don Guillett[_4_]

Find a . (period)
 
Long day

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
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.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
since you said left to right, better yet to try using instrrev

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
Have a look in vba help index for instr

--
Don Guillett
SalesAid Software

"Todd Huttenstine" wrote in

message
...
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










All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com