Determine data type in a string

N

news.epix.net

Could someone please tell me how to determine the data type of each char of
a string?

I have worksheets named 'October07'. I need to extract just the month name
first and then
the year number.

I would like to loop thru the string until I find an integer character.

Thanks,
M. Miller
 
B

Bob Phillips

=LEFT(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

Dave Peterson

You can use isnumeric.

dim lCtr as long
dim myWord as string
dim myStr as string
myWord = "October07"
myStr = ""
for lctr = 1 to len(myword)
if isnumeric(mid(myword, lctr, 1)) then
'get out, we're done
exit for
else
myStr = mystr & mid(myword, lctr, 1)
end if
next lctr
msgbox mystr

(Watch for typos!)
 
B

Bob Phillips

Missed year number

=MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),99)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

Ron Rosenfeld

Could someone please tell me how to determine the data type of each char of
a string?

I have worksheets named 'October07'. I need to extract just the month name
first and then
the year number.

I would like to loop thru the string until I find an integer character.

Thanks,
M. Miller

If your worksheets are all named with the last two characters being numeric,
then

Month = left(ws.name,len(ws.name)-2)
Year = right(ws.name,2) + 2000


--ron
 

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

Top