以下是实现您要求的 VBA 代码:

Sub CopyCNumbers()

    Dim lastRow As Long
    Dim i As Long
    Dim cellValue As String
    Dim cNumber As String
    
    lastRow = Cells(Rows.Count, "H").End(xlUp).Row
    
    For i = 1 To lastRow
        cellValue = Cells(i, "H").Value
        If InStr(cellValue, "C") > 0 Then
            cNumber = Mid(cellValue, InStr(cellValue, "C") + 1)
            Cells(i, "I").Value = "C" & cNumber
        End If
    Next i
    
End Sub

将此代码复制到您的 Excel 文件中的 VBA 编辑器中(按 Alt + F11 打开)。然后,选择要运行代码的工作表,并按 F5 运行它。它将扫描 H 列中的所有单元格,如果找到以 'C' 开头的字符串,则将其复制到相应的 I 列单元格中。

Excel VBA 代码:提取 H 列中以 'C' 开头的数字到 I 列

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

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