Excel精英培训网

 找回密码
 注册
查看: 1233|回复: 0

查找A列与B列相同值

[复制链接]
发表于 2015-5-16 20:36 | 显示全部楼层 |阅读模式
Sub 查找()
Dim a As Integer
Dim b(1 To 63356) As String
Dim c As Integer, d As Integer
c = 1: d = 1
a = WorksheetFunction.CountA(Range("a:a"))
Range("a1").Select
For x = 1 To a
If WorksheetFunction.CountIf(Range("b:b"), Selection) > 0 Then
b(c) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
c = c + 1
Else
ActiveCell.Offset(1, 0).Select
End If
Next
Range("c1").Select
For x = 1 To c - 1
ActiveCell.Value = b(d)
d = d + 1
ActiveCell.Offset(1, 0).Select
Next
End Sub

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-16 21:35 , Processed in 0.210691 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表