I need to extract data from a string into two new variables (called 'NHSNew' and 'NHSOld'). The string is mostly separated by a '/'. Data to the left of the string goes into 'NHSNew' and data to the right into 'NHSOld'. I can do this first part OK as shown below.
Data to the left of the '/':
IIf (InStr ([NHS Number new/old],"/"), Left ([NHS Number new/old], InStr([NHS Number new/old],"/")-1))
Data to the right of the '/':
IIf (InStr ([NHS Number new/old],"/"), LTrim (Mid ([NHS Number new/old], 15)))
However, some of the data will contain only the first part of the string ('456 585 8975'), or the second ('MSKI 105') without the '/'. An added complication is that the second part of the string does not have a consistent format. In these cases, how do I extract the relevant data into the correct variable?
TIA
Data to the left of the '/':
IIf (InStr ([NHS Number new/old],"/"), Left ([NHS Number new/old], InStr([NHS Number new/old],"/")-1))
Data to the right of the '/':
IIf (InStr ([NHS Number new/old],"/"), LTrim (Mid ([NHS Number new/old], 15)))
However, some of the data will contain only the first part of the string ('456 585 8975'), or the second ('MSKI 105') without the '/'. An added complication is that the second part of the string does not have a consistent format. In these cases, how do I extract the relevant data into the correct variable?
TIA