Cel K14 contains 'johan van der sterren'.
When I put the name hardcoded everything works fine
Anyone an idea why the first code goes wrong? Thanks and best regards
VBA Code:
Sub LastName()
name = [K14].Value
MsgBox name ' shows johan van der sterren
spot = InStrRev(name, " ")
MsgBox spot ' shows 22 but it schould be 14; find the last space and count from the beginning
MsgBox Mid(name, spot) ' shows space
End Sub
When I put the name hardcoded everything works fine
VBA Code:
Sub LastName()
name = "johan van der sterren"
MsgBox name ' shows johan van der sterren
spot = InStrRev(name, " ")
MsgBox spot ' shows 14; OK
MsgBox Mid(name, spot) ' shows sterren
End Sub
Anyone an idea why the first code goes wrong? Thanks and best regards