I want delete text and hyphen to the right, in Excel.
My column example:
Fresh Start Recovery, Inc. - Wayne
FSA Property Mgmt - Danny
Georgia Securing Svcs, Inc. - Katrina
Georgia - SFFS - Joe & Roxana
Greenwood - Lonnie
Griffis Recovery, LLC - Tyler (5% WC)
Hi Cap, Inc. - Doug
I need the it to look like this:
Fresh Start Recovery, Inc.
FSA Property Mgmt
Georgia Securing Svcs, Inc.
Georgia - SFFS
Greenwood
Griffis Recovery, LLC
Hi Cap, Inc.
I have code that will delete the text and hyphen to the right, but if I have two hyphens I need it to delete the second one, my code deletes the first one.
Dim iPos As String
Dim c As Range
For Each c In Range("a1:a" & Range("a" & Rows.Count).End(xlUp).Row)
iPos = InStr(1, c.Value, " - ")
If iPos > 0 Then
c.Value = Left(c.Value, iPos - 1)
End If
Next
End Sub
InStrRevfinds the last string match by looking backwards.This updated code
InStrRevto find the position of the last occurrenceuses the string function
Left$rather than the variantLeft