Thread: Easy Question
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Easy Question

Hi HolyEarth,

Try:

'=============
Public Sub Tester()
Dim rng As Range
Dim rCell As Range
Dim pos As Long

Set rng = ActiveSheet.Range("A1:A100") '<<==== CHANGE

For Each rCell In rng.Cells
With rCell
pos = InStr(1, .Value, "-")
If pos 0 Then
.Value = Left(.Value, pos - 1)
End If
End With
Next rCell
End Sub
'<<=============


---
Regards,
Norman



"holyearth" wrote
in message ...

I've got several rows of text as follows:

Apples are nice - So are pears
Monkeys are kind - So are dogs
Earth is beautiful - So is mars

I want to delete the space before the minus sign and everything after
by way of a macro...

So, all I want left is:

Apples are nice
Monkeys are kind
Earth is beautiful

Can someone help me with this?
Thanks guys, I appreciate your time.


--
holyearth
------------------------------------------------------------------------
holyearth's Profile:
http://www.excelforum.com/member.php...o&userid=34022
View this thread: http://www.excelforum.com/showthread...hreadid=549103