Excel精英培训网

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

VBA第7讲习题---学员答案上传专贴

[复制链接]
发表于 2008-6-18 17:16 | 显示全部楼层

游客,如果您要查看本帖隐藏内容请回复
</p><p>+7</p><p>&nbsp;</p>
[此贴子已经被laosanjie于2008-6-18 17:47:40编辑过]
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
回复

使用道具 举报

发表于 2008-6-18 18:13 | 显示全部楼层

游客,如果您要查看本帖隐藏内容请回复
</p><p>+2</p><p>&nbsp;</p>
[此贴子已经被laosanjie于2008-6-19 15:50:03编辑过]
回复

使用道具 举报

发表于 2008-6-20 17:13 | 显示全部楼层

补交第七讲作业。7个题。

游客,如果您要查看本帖隐藏内容请回复
</p><p>第5、7两题,重新看了录像,才明白。</p><p>第一题:隐藏A和B列都为空的行。</p><p>Sub 隐藏()<br/>&nbsp;Dim x As Range, y As Range<br/>&nbsp; Set x = Range("a1:a14").SpecialCells(xlCellTypeBlanks)<br/>&nbsp; Set y = Range("b1:b14").SpecialCells(xlCellTypeBlanks).Offset(, -1)<br/>&nbsp; Intersect(x, y).EntireRow.Hidden = True<br/>End Sub</p><p>第二题:隔行插入空行</p><p>Sub 隔行插入空行()<br/>&nbsp;Dim i%, z%<br/>&nbsp;On Error GoTo 100<br/>100:<br/>&nbsp; z = InputBox("请输入每行间插入的空行数量", "确定想插入的行数")<br/>&nbsp; For i = Range("b65536").End(xlUp).Row To 3 Step -1<br/>&nbsp;&nbsp; Rows(i &amp; ":" &amp; i + z - 1).Insert<br/>&nbsp; Next i<br/>End Sub</p><p>第三题:查找最右最下空值的单元格</p><p>Sub 查找空单元()<br/>&nbsp;MsgBox "最右最下空值单元格地址是:" &amp; Range("a1:d12").Find("", searchorder:=xlByRows, searchdirection:=xlPrevious).Address(0, 0)<br/>End Sub</p><p>第四题:列的合并</p><p>Sub 合并()<br/>&nbsp;Dim x%<br/>&nbsp; For x = 2 To 12<br/>&nbsp;&nbsp; Cells(x, "f") = Cells(x, "e").End(xlToLeft)<br/>&nbsp; Next x<br/>End Sub</p><p>第五题:取不重复值</p><p>Sub 取不重复值()<br/>&nbsp;Dim aa As Range<br/>&nbsp; For Each aa In Range("a1:d12")<br/>&nbsp;&nbsp; If aa &gt;= "D" And aa &lt;= "W" Then<br/>&nbsp;&nbsp;&nbsp; If Application.CountIf(Range("f:f"), aa) = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp; Range("f65536").End(xlUp).Offset(1, 0) = aa<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp; End If<br/>&nbsp; Next aa<br/>End Sub</p><p>第六题:合并单元格</p><p>Sub 合并单元格()<br/>&nbsp;Dim x%<br/>&nbsp; For x = Range("a65536").End(xlUp).Row To 2 Step -1<br/>&nbsp;&nbsp;&nbsp; If Cells(x, 1) = Cells(x - 1, 1) Then<br/>&nbsp;&nbsp;&nbsp;&nbsp; Application.DisplayAlerts = False<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Range(Cells(x, 1), Cells(x - 1, 1)).Merge<br/>&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp; Next x<br/>&nbsp; Application.DisplayAlerts = True<br/>End Sub</p><p>第七题:求和</p><p>Sub 求和()<br/>&nbsp;Dim x%<br/>&nbsp; For x = 2 To Range("c65536").End(xlUp).Row<br/>&nbsp;&nbsp; If Cells(x, 1) &lt;&gt; "" Then<br/>&nbsp;&nbsp;&nbsp; Cells(x, 4) = Application.Sum(Cells(x, 3).Resize(Cells(x, 1).MergeArea.Count))<br/>&nbsp;&nbsp; End If<br/>&nbsp; Next x<br/>End Sub<br/></p><p>[/hide]</p><p>+7</p><p>&nbsp;</p>
[此贴子已经被laosanjie于2008-6-20 20:48:54编辑过]
回复

使用道具 举报

发表于 2008-6-22 10:20 | 显示全部楼层

学习学习
回复

使用道具 举报

发表于 2008-9-7 12:02 | 显示全部楼层

<p>不错,学习中</p>
回复

使用道具 举报

发表于 2008-10-30 20:44 | 显示全部楼层

0
回复

使用道具 举报

发表于 2011-10-10 20:26 | 显示全部楼层
找不到下载的方法

回复

使用道具 举报

发表于 2011-10-10 20:47 | 显示全部楼层
来学习
回复

使用道具 举报

发表于 2015-5-25 18:20 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

发表于 2016-1-29 19:47 | 显示全部楼层
gfffd
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-7 13:48 , Processed in 0.266759 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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