Consulting

Results 1 to 3 of 3

Thread: Help with VBA Text Function (Right,Left,Mid)

  1. #1
    VBAX Regular
    Joined
    Dec 2017
    Posts
    43
    Location

    Help with VBA Text Function (Right,Left,Mid)

    Hello,

    I a trying to select the middle text from a column field and I am getting stuck on the last part.

    this is how my names are displayed in my column:

    Last_Name,First_Name Middle_Initial

    I only want the First Name and the code I have now is:

    Right([Names],InStr(1,[Names],",")-2) which returns, First_Name Middle Initial for example Doe,John M = John M

    I cant seem to get ride of the Middle Initial any help s greatly appreciated.


    Sincerely,
    KDC900

  2. #2
    VBAX Contributor
    Joined
    Aug 2012
    Posts
    120
    Location
    Dim nms as string
    nms = DOE,John M
    nms = Right(nms, Len(nms) - Instr(1, nms, ",")) 'Yields, "John M"
    nms = Left(nms, Len(nms) - 2) 'Yields "John"

  3. #3
    VBAX Regular
    Joined
    Dec 2017
    Posts
    43
    Location
    Thank you so much for your help Mavila

Tags for this Thread

Posting Permissions

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