用VBA代码如下:
Sub sc()
Dim i As Integer, n As Byte
i = 2
Do While Cells(i, 1) <> ""
If IsError(Application.Find(",", Cells(i, 1))) Then
Cells(i, 1) = Cells(i, 1)
Else
n = Application.Find(",", Cells(i, 1)) - 1
Cells(i, 1) = Left(Cells(i, 1), n)
End If
i = i + 1
Loop
End Sub
效果如下(若图片没有显示动画,点一下图片即可)