2个回答
展开全部
Sub s()
Dim rg1 As Range, rg2 As Range
Set rg1 = [n10:t10]
t1 = Left([s9], 1)
For Each rg2 In rg1
If Left(rg2, 1) = t1 Then t = "A": Exit For
Next
t1 = Right([s9], 1)
For Each rg2 In rg1
If Right(rg2, 1) = t1 Then t = t & "B": Exit For
Next
[k8] = t
End Sub
追问
当都没有找到时,返"没"
追答
Sub s()
Dim rg1 As Range, rg2 As Range
Set rg1 = [n10:t10]
t1 = Left([s9], 1)
For Each rg2 In rg1
If Left(rg2, 1) = t1 Then t = "A": Exit For
Next
t1 = Right([s9], 1)
For Each rg2 In rg1
If Right(rg2, 1) = t1 Then t = t & "B": Exit For
Next
If t = "" Then t = "没"
[k8] = t
End Sub
来自:求助得到的回答
展开全部
Dim rng as Range
Range("K8").Clear '清除K8单元格内容
For Each rng in Range("N10:T10") '遍历N10:T10的所有单元格
'若单元格内容与S9相同,则将单元格坐标添加至K8
If rng = Range("S9") Then Range("K8").Text = Range("K8").Text & " " & rng.Address
Next rng
由于题主写得很含糊“找出相同位置内容”,因此代码只是示例,将匹配的单元格地址坐标保存,并假设可能存在多个匹配结果。如果需要其他信息,可自行修改代码。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询