写一个excel的vba逻辑是检查H列的数据不限字符数找到单元格中C+数字不限字符数的字符并删除其后面的字符
Sub DeleteAfterCNumber() Dim lastRow As Long Dim cell As Range Dim str As String Dim i As Integer
lastRow = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row
For Each cell In Range("H2:H" & lastRow)
str = cell.Value
If Left(str, 1) = "C" Then
For i = 2 To Len(str)
If Not IsNumeric(Mid(str, i, 1)) Then
cell.Value = Left(str, i - 1)
Exit For
End If
Next i
End If
Next cell
End Sub
原文地址: https://www.cveoy.top/t/topic/bjrx 著作权归作者所有。请勿转载和采集!