Regular Member
|
公式可以解決的問題,應該使用公式。
VBA沒有比較聰明。
Sub xxx()
Set currgn = ActiveCell.CurrentRegion
Set c = currgn.Find("*姓*名*")
If Not c Is Nothing Then
Range(c.Address).Offset(1, 0).Select
Else
Exit Sub
End If
While ActiveCell.Value <> ""
If ActiveCell.Offset(0, 1).Value <> "" Then
ActiveCell.Offset(0, -1).Value = Right(ActiveCell.Offset(0, 1).Value, 5)
End If
If ActiveCell.Offset(0, 2).Value <> "" Then
ActiveCell.Offset(0, -1).Value = Right(ActiveCell.Offset(0, 2).Value, 5)
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub
|