PDA

View Full Version : Help with VBA Text Function (Right,Left,Mid)



KDC900
06-18-2018, 12:13 PM
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

Mavila
06-21-2018, 11:49 AM
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"

KDC900
06-21-2018, 12:15 PM
Thank you so much for your help Mavila :)