A bit improved (and tested....)
Tim
**********************************************
Option Explicit
Function GetState(val) As String
Dim retval
Dim c As Range
Dim temp
retval = "Not found"
If Len(val) > 0 Then
'adjust the range to suit....
For Each c In ThisWorkbook.Sheets("List").Range("A1:A100")
If UCase(val) Like "*" & UCase(c.Value) & "*" Then
retval = c.Offset(0, 1).Value
Exit For
End If
Next c
End If
GetState = retval
End Function
**********************************************
--
Tim Williams
Palo Alto, CA
"Tim Williams" <timjwilliams at gmail dot com> wrote in message
news:e8mJD70KGHA.2628@TK2MSFTNGP15.phx.gbl...
> How many possible distinct strings are there ? Do you have a list of them
?
>
> You could create a function which would scan the list and return the
State.
>
> Eg, (untested) with a sheet "List" which lists your strings in column A
and
> their matching states in col B
>
> **********************************************
> Function GetState(val) as string
>
> dim retval
> dim c as range
> dim temp
>
> retval="Not found"
> if len(val)>0 then
> 'adjust the range to suit....
> for each c in thisworkbook.sheets("List").range("A1:A100")
>
> if ucase(val) like "*" & ucase(c.value) & "*" then
> retval=c.offset(0,1).value
> end if
>
> next c
> end if
>
> GetState = retval
> end function
> *********************************************
>
>
>
> --
> Tim Williams
> Palo Alto, CA
>
>
> "mjj047s" <mattjohnston333@netscape.net> wrote in message
> news:1139248784.941455.159530@g47g2000cwa.googlegroups.com...
> > Ok - I hope I world this correctly.
> > I have two coumns. Column A is blank, and Column B has different item
> > descriptions. Instead of manually looking through column B to
> > determine what to type in A, can i have a formula do that?
> > EXAMPLE - lets use State Abbreviations -
> >
> > Column B1 says - ILLINOIS DEPT OF;PAYMENT INITIATED - REVENUE ID =
> > 3423455
> > another column (B2) says - DEPT OF REVENUE ; MO DOR - PAYMENT ACCEPTED
> > -
> > and so on and so on....
> >
> >
> > The purpose of Column A is to identify column B in two state letters
> >
> > Every Illinois description will say " ILLINOIS DEPT OF" in column B. So
> > every column that says that, i want column A to say "IL"
> >
> > Every Missouri description will say "MO DOR"in column B. So every
> > column that says that, i want column A to say "MO"
> >
> > Make sense? I hope so -
> > basically - search for a string of text, if you find THAT STRING put
> > "this" in Column A, otherwise search for another string of text, if you
> > find THAT STRING put "that" in Column A, and so on....
> >
> > sorry for being so confusing. Basically, i don't want to have to go
> > through 1000 descriptions every month to identify a State.
> >
> >
> > mj
> >
>
>
Bookmarks