excel提取单元格内某字符后面一位的数据全部提取出来 用vba实现
如图,把AB两列张三后面一位的全部提取出来,并且用+隔开,提取出来的数据应是C列用vba怎么写出来?...
如图,把AB两列张三后面一位的全部提取出来,并且用+隔开,提取出来的数据应是C列用vba怎么写出来?
展开
2个回答
推荐于2016-01-18
展开全部
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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列中第一个张三后面的数字
然后下拉
这个可以实现提取A和B列中第一个张三后面的数字
追答
有限定一个单元格里面可以有几个张三吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |