写一个excel的vba逻辑是检查H列的数据不限字符数找到单元格中符合C+数字的字符并剪切其后面的字符然后黏贴到L
列。
Sub CutAndPaste() Dim i As Long Dim lastRow As Long lastRow = Cells(Rows.Count, "H").End(xlUp).Row
For i = 1 To lastRow
If InStr(Cells(i, "H").Value, "C") > 0 Then
Dim str As String
str = Cells(i, "H").Value
Dim numIndex As Long
numIndex = InStr(str, "C") + 1
If IsNumeric(Mid(str, numIndex, 1)) Then
Dim cutStr As String
cutStr = Mid(str, numIndex)
Cells(i, "H").Value = Left(str, numIndex - 1)
Cells(i, "L").Value = cutStr
End If
End If
Next i
End Sub
原文地址: https://www.cveoy.top/t/topic/bi4s 著作权归作者所有。请勿转载和采集!