ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IF Functions for Text in Excel 2000 (https://www.excelbanter.com/excel-programming/318705-if-functions-text-excel-2000-a.html)

BarnyardJoe

IF Functions for Text in Excel 2000
 
I am trying to separate city, state, zip from 1 cell to 3 by using the IF
function. But I cannot get the IF function to recognize text values, only
numeric. I have already changed the cells format to text, but to no avail.
Any suggestions? Can it be done in excel?

Frank Kabel

IF Functions for Text in Excel 2000
 
Hi
see your other post

--
Regards
Frank Kabel
Frankfurt, Germany

BarnyardJoe wrote:
I am trying to separate city, state, zip from 1 cell to 3 by using
the IF function. But I cannot get the IF function to recognize text
values, only numeric. I have already changed the cells format to
text, but to no avail. Any suggestions? Can it be done in excel?




Tom Ogilvy

IF Functions for Text in Excel 2000
 
if you are using xl2000 or later

Sub Addr()
Dim sStr As String, v As Variant
Dim lCity As Long, zip As String
Dim city As String, state As String
sStr = "Los Angeles, CA 90210"
Range("A1").Value = sStr
v = Split(Range("A1").Value, " ")

lCity = UBound(v) - 2
zip = Trim(v(UBound(v)))
state = Trim(v(UBound(v) - 1))
city = ""
For i = 0 To lCity
city = city & Trim(v(i)) & " "
Next
city = Trim(Replace(city, ",", ""))
Debug.Print city, state, zip

End Sub

for string like

Los Angeles, CA 90210


--
Regards,
Tom Ogilvy


"BarnyardJoe" wrote in message
...
I am trying to separate city, state, zip from 1 cell to 3 by using the IF
function. But I cannot get the IF function to recognize text values, only
numeric. I have already changed the cells format to text, but to no

avail.
Any suggestions? Can it be done in excel?





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

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