Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1558|回复: 3

[习题] 代码报错

[复制链接]
发表于 2012-12-28 20:26 | 显示全部楼层 |阅读模式
第二题有点问题,请老师指点一下
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
 楼主| 发表于 2012-12-28 20:27 | 显示全部楼层
第11集练习题.zip (9.34 KB, 下载次数: 5)
回复

使用道具 举报

发表于 2012-12-28 20:37 | 显示全部楼层
  1. Sub zhoucs00()
  2. Dim rng As Range, rngg As Range
  3. For Each rng In Range("A2:C12")
  4.    If VBA.IsNumeric(rng.Value) And rng > 0 Then
  5.       If rngg Is Nothing Then
  6.          Set rngg = rng
  7.       Else
  8.          Set rngg = Application.Union(rngg, rng)
  9.       End If
  10.    End If
  11. Next rng
  12. rngg.EntireRow.Select
  13. 'MsgBox rngg.Address(0, 0)
  14. End Sub
复制代码
试下这段代码如何。。
回复

使用道具 举报

发表于 2012-12-28 22:23 | 显示全部楼层
本帖最后由 490540970 于 2012-12-28 22:25 编辑

Private Sub CommandButton1_Click()
Dim rng As Range
Dim str As String
For Each rng In Range("a2:c12")
    If VBA.IsNumeric(rng.Value) And rng.Value > 0 Then
        str = str & rng.Row & ":" & rng.Row & ","
    End If
Next
str = Left(str, Len(str) - 1)
Range("" & str).Select
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If VBA.IsNumeric(Target.Value) And Target.Value > 0 Then Target.Value = "正数"
End Sub
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 16:24 , Processed in 0.343702 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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