Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
楼主: 兰色幻想

[习题] VBA第8讲作业答案上传贴

[复制链接]
发表于 2008-1-16 16:13 | 显示全部楼层
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
回复

使用道具 举报

发表于 2008-1-16 16:43 | 显示全部楼层

<p>Sub 物品1有物品2没有()<br/>&nbsp; Range("e2:e65536") = ""<br/>&nbsp; Dim arr1, arr2, z%, x%, y%<br/>&nbsp; arr1 = Range("a2:a" &amp; [a65536].End(xlUp).Row)<br/>&nbsp; arr2 = Range("b2:b" &amp; [b65536].End(xlUp).Row)<br/>&nbsp; For y = 1 To [a65536].End(xlUp).Row - 1<br/>&nbsp;&nbsp;&nbsp; For x = 1 To [a65536].End(xlUp).Row - 1<br/>&nbsp;&nbsp;&nbsp; z = [e65536].End(xlUp).Row + 1<br/>&nbsp;&nbsp;&nbsp; If arr1(y, 1) = arr2(x, 1) Then GoTo 100<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp; Range("e" &amp; z) = arr1(y, 1)<br/>100:<br/>&nbsp; Next<br/>End Sub</p><p>Sub 物品2有物品1没有()<br/>&nbsp; Range("f2:f65536") = ""<br/>&nbsp; Dim arr1, arr2, z%, x%, y%<br/>&nbsp; arr1 = Range("a2:a" &amp; [a65536].End(xlUp).Row)<br/>&nbsp; arr2 = Range("b2:b" &amp; [b65536].End(xlUp).Row)<br/>&nbsp; For y = 1 To [b65536].End(xlUp).Row - 1<br/>&nbsp;&nbsp;&nbsp; For x = 1 To [a65536].End(xlUp).Row - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z = [f65536].End(xlUp).Row + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If arr2(x, 1) = arr1(y, 1) Then GoTo 100<br/>&nbsp;&nbsp;&nbsp; Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range("f" &amp; z) = arr2(y, 1)<br/>100:<br/>&nbsp; Next<br/>End Sub<br/></p>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-6-26 09:35 , Processed in 0.089305 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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