我需要一个excel的vba逻辑是检查H列中的值复制其中C+数字字符到I列
以下是实现您要求的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列单元格中。
原文地址: https://www.cveoy.top/t/topic/bilV 著作权归作者所有。请勿转载和采集!