Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find letter vrs number

Hi I need to have vba look at a var and determine if the first character
is number or letter and if letter then make a new var from begging to
first space. Can someone help thanks in advance
Rod Taylor


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default find letter vrs number

Something like:

If Not IsNumeric(Left(var, 1)) Then newvar = Left("b34 s", InStr(1, var, "
") - 1)

This assumes that the variable "var" always contains a space if it begins
with a letter.

--

Vasant


"rjtaylor " wrote in message
...
Hi I need to have vba look at a var and determine if the first character
is number or letter and if letter then make a new var from begging to
first space. Can someone help thanks in advance
Rod Taylor


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find letter vrs number

Some possible enhancements to the basic idea:

Sub Tester5()
Dim s, t, u, v, s1, t1, u1, v1
s = "123ABC": s1 = retText(s)
t = "ABC 456": t1 = retText(t)
u = "12 A 56 B": u1 = retText(u)
v = "abcdefgh": v1 = retText(v)
Debug.Print s, s1
Debug.Print t, t1
Debug.Print u, u1
Debug.Print v, v1
End Sub


Function retText(var)
retText = ""
If VarType(retText) = 8 Then
If Not IsNumeric(Left(var, 1)) Then
retText = Left(var, IIf(InStr(1, var, " ") = 0, _
Len(var), InStr(1, var, " ")))
End If
End If
End Function

Returns
ABC 456 ABC
12 A 56 B
abcdefgh abcdefgh

--
Regards,
Tom Ogilvy



Vasant Nanavati <vasantn *AT* aol *DOT* com wrote in message
...
Something like:

If Not IsNumeric(Left(var, 1)) Then newvar = Left("b34 s", InStr(1, var, "
") - 1)

This assumes that the variable "var" always contains a space if it begins
with a letter.

--

Vasant


"rjtaylor " wrote in message
...
Hi I need to have vba look at a var and determine if the first character
is number or letter and if letter then make a new var from begging to
first space. Can someone help thanks in advance
Rod Taylor


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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default find letter vrs number

"Tom Ogilvy" wrote...
....
Function retText(var)
retText = ""
If VarType(retText) = 8 Then

....

If you've just set retText to "", it's guaranteed to be a string, isn't it?
If so, isn't the following If test superfluous?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default find letter vrs number

No, it was a typo, thanks for pointing it out:

Function retText(var)
retText = ""
If VarType(var) = 8 Then
If Not IsNumeric(Left(var, 1)) Then
retText = Left(var, IIf(InStr(1, var, " ") = 0, _
Len(var), InStr(1, var, " ")))
End If
End If
End Function



--
Regards,
Tom Ogilvy



Harlan Grove wrote in message
...
"Tom Ogilvy" wrote...
...
Function retText(var)
retText = ""
If VarType(retText) = 8 Then

...

If you've just set retText to "", it's guaranteed to be a string, isn't

it?
If so, isn't the following If test superfluous?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find letter vrs number

I typed var for the word varable not the actual varable I assume tha
var is just the varable I dont understand functions yet

If VarType(var) = 8 Then
why is the 8 there

what does the IIf in
retText = Left(var, IIf(InStr(1, var, " ") = 0, _
mean

sorry I dont get it and thanks
Rod Taylor:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a number to a letter of the alphabet to get a letter [email protected] Excel Worksheet Functions 5 May 21st 07 04:25 PM
How do I find the total number of the same number/letter in a row Anne-Marie Excel Discussion (Misc queries) 9 October 21st 05 10:22 AM
change headers from letter to number/number to letter lazybee Excel Worksheet Functions 1 July 29th 05 11:08 PM
column header changed from letter to number, how return to letter Ron Excel Discussion (Misc queries) 2 May 9th 05 08:34 PM
Auto number w/ different letter-number combos in same column Colleen B Excel Worksheet Functions 2 February 23rd 05 02:41 PM


All times are GMT +1. The time now is 07:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"