Sub Check_H_Column() Dim lastRow As Long Dim i As Long Dim cellValue As String Dim cPosition As Long Dim numPosition As Long Dim strToCut As String

lastRow = ActiveSheet.Cells(Rows.Count, "H").End(xlUp).Row

For i = 1 To lastRow
    cellValue = ActiveSheet.Range("H" & i).Value
    cPosition = InStr(1, cellValue, "C")
    numPosition = InStr(cPosition, cellValue, " ")
    
    If cPosition > 0 And numPosition > 0 Then
        strToCut = Mid(cellValue, cPosition + 1, numPosition - cPosition - 1)
        ActiveSheet.Range("J" & i).Value = strToCut
        ActiveSheet.Range("H" & i).Value = Replace(cellValue, "C" & strToCut, "")
    End If
Next i

End Sub

Excel VBA: 从 H 列数据中提取 'C+数字' 后面的字符到 J 列

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

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