Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Okay, sorry for all the confusion. Here's the procedure we talked
about yesterday revised so that it will work whether or not there are any blank rows. I've tested it using the data you originally supplied and it works fine without errors. Just remember to set your range reference to whatever you have. I've commented the line in the code where you need to do this. Sub FirstToLast() Dim lkforComma As Integer Dim lkforSpace As Integer Dim fName, mName, lName As String Dim myRange As Range Dim myCell As Range Set myRange = Range("A1:A9") 'set the range for whateve you need For Each myCell In myRange If myCell < "" Then 'blank cells will be ignored Set nextCell = myCell.Offset(1, 0) Set firstName = myCell.Offset(0, 1) Set middleName = myCell.Offset(0, 2) Set lastName = myCell.Offset(0, 3) lkforComma = InStr(myCell, ",") lName = Left(myCell, lkforComma - 1) fName = Mid(myCell, lkforComma + 2) lkforSpace = InStr(fName, Chr(32)) mName = Mid(fName, lkforSpace + 1) fName = Mid(fName, 1, lkforSpace - 1) firstName.Value = fName middleName.Value = mName lastName.Value = lName End If Set myCell = nextCell Next myCell MsgBox "File Done" End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
parsing a full name out into Last, First, Middle | Excel Worksheet Functions | |||
Formulas for Parsing Full names | Excel Worksheet Functions | |||
how do I find names in a workbook full of names | Excel Discussion (Misc queries) | |||
TypeLib Information Problem? Pass a Function's parameter names as string for parsing? | Excel Programming | |||
Parsing Full Names of varying lenths and parts | Excel Programming |