Consulting

Results 1 to 3 of 3

Thread: Solved: separate text

  1. #1

    Solved: separate text

    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.

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

    txtState =
    [/vba]

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Try:
    [vba]txtCity = Split(Application.WorksheetFunction.VLookup(Range("CB10").Offset(frmCalc.Li stBox3.ListIndex + 1, 0).Value, rRange, 8, False),", ")(0)
    txtState = Split(Application.WorksheetFunction.VLookup(Range("CB10").Offset(frmCalc.Li stBox3.ListIndex + 1, 0).Value, rRange, 8, False),", ")(1)[/vba]
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Works great. Thank you macropod

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •