Sub DeleteCPlusNum() Dim lastRow As Long Dim i As Long Dim cellValue As String Dim j As Long Dim k As Long Dim char As String

'获取最后一行
lastRow = Cells(Rows.Count, "H").End(xlUp).Row

For i = 1 To lastRow
    cellValue = Cells(i, "H").Value
    j = InStr(1, cellValue, "C")
    If j > 0 Then
        For k = j + 1 To Len(cellValue)
            char = Mid(cellValue, k, 1)
            If IsNumeric(char) Then
                Exit For
            End If
        Next k
        If k <= Len(cellValue) Then
            Cells(i, "H").Value = Left(cellValue, j - 1) & Mid(cellValue, k + 1)
        End If
    End If
Next i

End Sub

写一个excel的vba逻辑是检查H列的数据不限字符数找到单元格中符合C+数字后面的字符并删除

原文地址: https://www.cveoy.top/t/topic/bjsD 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录