excel提取单元格内某字符后面一位的数据全部提取出来 用vba实现
发布网友
发布时间:2022-05-17 12:51
我来回答
共2个回答
热心网友
时间:2023-10-22 08:27
Sub TEST()
Dim arr1() As String
Dim arr2() As String
Dim txt1, txt2, txt3 As String
For i = 1 To Range("A65536").End(xlUp).Row
arr1() = Split(Cells(i, 1), "张三")
If UBound(arr1) > 0 Then
For a = 1 To UBound(arr1)
txt1 = txt1 & Left(arr1(a), 1) & "+"
Next a
End If
arr2() = Split(Cells(i, 2), "张三")
If UBound(arr2) > 0 Then
For b = 1 To UBound(arr2)
txt2 = txt2 & Left(arr2(b), 1) & "+"
Next b
End If
txt3 = txt1 & txt2
If txt3 <> "" Then
txt3 = Left(txt3, Len(txt3) - 1)
Cells(i, 3).Value = txt3
End If
txt1 = ""
txt2 = ""
txt3 = ""
Next i
End Sub
热心网友
时间:2023-10-22 08:27
C1=IF(ISERROR(FIND("张三",A1)),"",MID(A1,FIND("张三",A1)+2,1))&IF(OR(ISERROR(FIND("张三",A1)),ISERROR(FIND("张三",B1))),"","+")&IF(ISERROR(FIND("张三",B1)),"",MID(B1,FIND("张三",B1)+2,1))
然后下拉
这个可以实现提取A和B列中第一个张三后面的数字追答有限定一个单元格里面可以有几个张三吗?