PDA

View Full Version : Solved: separate text



av8tordude
05-12-2011, 06:31 PM
In the cell is the City, State (i.e. Miami, Florida). I have this code that populates txtCity text box with the City, State. I would like to separate them and populate two different textboxes (i.e. txtCity & txtState). Currently the txtCity textboxes displays both the city & state in one textbox. I only what txtCity to show the City (i.e Miami) and txtState to only show the State (i.e. Florida). Can someone assist with modifying this code to achieve this. Thank you.

txtCity = Application.WorksheetFunction.VLookup(Range("CB10").Offset(frmCalc.ListBox3.ListIndex + 1, 0).Value, rRange, 8, False)

txtState =

macropod
05-12-2011, 08:20 PM
Try:
txtCity = Split(Application.WorksheetFunction.VLookup(Range("CB10").Offset(frmCalc.ListBox3.ListIndex + 1, 0).Value, rRange, 8, False),", ")(0)
txtState = Split(Application.WorksheetFunction.VLookup(Range("CB10").Offset(frmCalc.ListBox3.ListIndex + 1, 0).Value, rRange, 8, False),", ")(1)

av8tordude
05-13-2011, 09:29 AM
Works great. Thank you macropod:beerchug: