Hoping someone can help me with this -
I basically have a sheet that includes data like so:
AAA-IK-10
BBB-09
CCC
DDD-TT-2XL
EEE-R-L
And I need a Worksheet_Change macro that runs through column "A" and deletes any data after the last hyphen, if the data corresponds to a list like so:
-S
-M
-09
-10
etc.
Can someone help?
I found this macro which does a similar job (but not the same) but i can't modify it correctly:
Code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Long
Dim Pos As Long
Dim i As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
Pos = InStrRev(.Cells(i, "A").Value, "-")
If Pos > 0 Then
.Cells(i, "A").Value = Left(.Cells(i, "A").Value, Pos - 1)
End If
Next i
End With
End Sub
Display More
Thanks in anticipation.
- jg2703