Excel精英培训网

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

VBA80集第11集练习题答案上交贴

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

使用道具 举报

发表于 2017-12-5 14:38 | 显示全部楼层
回复

使用道具 举报

发表于 2017-12-5 19:32 | 显示全部楼层
回复

使用道具 举报

发表于 2017-12-6 15:15 | 显示全部楼层
好好学习,天天向上
回复

使用道具 举报

发表于 2017-12-6 17:30 | 显示全部楼层
好像来晚了。。。。。
回复

使用道具 举报

发表于 2017-12-6 19:07 | 显示全部楼层
参观

回复

使用道具 举报

发表于 2017-12-6 19:47 | 显示全部楼层
本帖最后由 optimus 于 2017-12-6 20:20 编辑
  1. Sub positive()
  2. Dim rg As Range, m As Integer, i As Integer

  3. i = 1
  4. Set rg = Selection
  5. m = Selection.Cells.Count
  6. 'range(selction),range"a1"
  7.     For i = 1 To m
  8.         If Application.WorksheetFunction.IsNumber(rg.Cells(i)) = True Then
  9.         
  10.             If Selection.Cells(i) > 0 Then
  11.             Selection.Cells(i) = "正数"
  12.             End If
  13.         End If
  14.     Next i

  15. End Sub

  16. Sub selct()
  17. Dim rng As Range, rng2 As Range, rng1 As Range

  18. Dim i As Integer

  19. Set rng = Range("a2:c12")
  20. Set rng2 = Nothing

  21. For i = 1 To rng.Cells.Count Step 1
  22.     If Application.WorksheetFunction.IsNumber(rng.Cells(i)) = True And rng.Cells(i) > 0 Then
  23.        If (rng2 Is Nothing) Then
  24.         Set rng2 = rng.Cells(i)
  25.        End If
  26.         Set rng2 = Union(rng2, rng.Cells(i))
复制代码
怎么在选中的单元格集合里面剔除某个单元格?
例如
range("a1:c10").select
怎么剔除里面的B2?

用第二个程序选择了多行数据后,再用第一个数据替换数字为“正数“,为什么有部分替换不了?
循环次数有限制吗?
捕获.JPG
捕获2.JPG
回复

使用道具 举报

发表于 2017-12-7 20:34 | 显示全部楼层
参考一下
回复

使用道具 举报

发表于 2017-12-14 21:00 | 显示全部楼层
Sub zhengshu()
Dim rg As Range
For Each rg In Selection
    If VBA.IsNumeric(rg.Value) And rg.Value > 0 Then
        rg.Value = "正数"
    End If
Next
End Sub
回复

使用道具 举报

发表于 2017-12-15 11:04 | 显示全部楼层
找答案
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-6 11:24 , Processed in 0.377381 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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