How do I remove all text in a cell after a specific character?

E

Erik Millerd

I have a cell linked to an Access database field. This field contains carrage
returns. I want to display only the data before the 1st carrage return. Is
there a way to do this? Perhaps useing the LEN, LEFT and other functions?
BTW this is in Excle and Access 2000.
 
M

moi

I don't know if that will work with a worksheet function because i don't
know how to search for for an enter. With a VBA function it's easier:

Public Function OnlyB4Enter(wCell As String) As String
Dim i, l As Integer
Dim txtResult As String
l = Len(wCell)
i = InStr(1, wCell, vbCrLf, vbTextCompare)
If i > 0 Then
txtResult = Left(wCell, (i - 1))
Else
txtResult = wCell
End If
OnlyB4Enter = txtResult
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top