Excel精英培训网

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

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

  [复制链接]
发表于 2022-9-22 11:24 | 显示全部楼层
现在还能不能回复啊
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
回复

使用道具 举报

发表于 2022-9-24 17:35 | 显示全部楼层
回复

使用道具 举报

发表于 2022-9-29 18:11 | 显示全部楼层
回复

使用道具 举报

发表于 2022-10-5 16:36 | 显示全部楼层
啊甘学VBA 发表于 2022-2-23 12:57
'题目2:用代码一次选取“A2:C12”区域所有大于0数字所在的行
Sub t2()
Dim x, y As Range

这个是我看最简介的,但是这个没有判断cells(2,1)
回复

使用道具 举报

发表于 2022-10-8 15:38 | 显示全部楼层
看看
回复

使用道具 举报

发表于 2022-10-8 15:47 | 显示全部楼层
看看
回复

使用道具 举报

发表于 2022-10-10 11:42 | 显示全部楼层
看答案
回复

使用道具 举报

发表于 2022-10-15 19:54 | 显示全部楼层
Sub t101()
Dim newRange As Range
Set newRange = Application.InputBox(prompt:="请用鼠标选定一个区域", Title:="返回区域类所有大于0数字所在的行", Type:=8)
newRange.Select
Dim x As Integer, y As Integer, row_id As Integer, column_id As Integer
x = Selection.Rows.Count
y = Selection.Columns.Count
row_id = ActiveCell.Row
column_id = ActiveCell.Column
Dim x1 As Integer, y1 As Integer
Dim rg As Range, isx As Integer

For x1 = row_id To (row_id + x - 1) Step 1
    For y1 = column_id To (column_id + x - 1) Step 1
    If (IsNumeric(Cells(x1, y1))) And Cells(x1, y1) > 0 And isx = 0 Then
        Set rg = Range(x1 & ":" & x1)
        isx = 1
             Else
              If (IsNumeric(Cells(x1, y1))) And Cells(x1, y1) > 0 And isx >= 1 Then
              Set rg = Union(rg, Range(x1 & ":" & x1))
              End If

     End If
    Next y1
Next x1

回复

使用道具 举报

发表于 2022-10-24 11:45 | 显示全部楼层
Sub 题目1()
Dim rg As Range
For Each rg In Selection
    If IsNumeric(rg) And rg.Value > 0 Then
        rg = "正数"
    End If
Next
End Sub



Sub 题目2()
Dim rg As Range
Dim r1 As Range
For Each rg In Range("A2:C12")
    If IsNumeric(rg) And rg.Value > 0 Then
        If r1 Is Nothing Then
            Set r1 = rg.EntireRow
        Else: Set r1 = Union(r1, rg.EntireRow)
        End If
    End If
Next
r1.Select
End Sub
回复

使用道具 举报

发表于 2022-10-27 17:26 | 显示全部楼层
学习下
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-2 09:27 , Processed in 0.556011 second(s), 5 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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