Excel精英培训网

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

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

  [复制链接]
发表于 2020-10-22 19:36 | 显示全部楼层
多少年了
回复

使用道具 举报

发表于 2020-10-23 17:07 | 显示全部楼层
回复

使用道具 举报

发表于 2020-10-31 11:16 | 显示全部楼层
回复

使用道具 举报

发表于 2020-10-31 11:48 | 显示全部楼层
小弟不才,把第二题的答案改写了。
Sub 正数标记该列()
    Dim rng As Range, rg As Range, flag As Boolean
    flag = True
    For Each rng In Range("A2:C12")
        If WorksheetFunction.IsNumber(rng) And rng > 0 And flag Then
            Set rg = rng
            flag = False
        ElseIf WorksheetFunction.IsNumber(rng) And rng > 0 Then
            Set rg = Union(rg, rng)
        End If
    Next rng
    rg.EntireRow.Select
End Sub
回复

使用道具 举报

发表于 2020-11-5 15:08 | 显示全部楼层
太不容易了
回复

使用道具 举报

发表于 2020-11-7 15:11 | 显示全部楼层
Sub exe1()

Dim x As Integer, y As Integer

For x = 1 To 20 Step 1

   For y = 1 To 3 Step 1

   If IsNumeric(Cells(x, y).Value) Then

     If Cells(x, y).Value > 0 Then

        Cells(x, y).Value = "正数"
        Cells(x, y).Font.ColorIndex = 3
    End If
   End If

    Next y
    Next x



End Sub


回复

使用道具 举报

发表于 2020-11-14 22:59 | 显示全部楼层

回复

使用道具 举报

发表于 2020-11-17 22:05 | 显示全部楼层
交作业:
Sub 改正数()
    Dim rng As Range
        For Each rng In Selection
            If VBA.IsNumeric(rng) And rng > 0 Then
                rng = "正数"
            End If
        Next
End Sub

Sub 选行()
    Dim rng As Range, rg As Range, i&
        For Each rng In [a2:c12]
            If IsNumeric(rng) And rng > 0 Then
                If i = 0 Then
                    Set rg = rng.EntireRow
                    i = 1
                Else
                    Set rg = Union(rg, rng.EntireRow)
                End If
            End If
        Next
        rg.Select
End Sub
回复

使用道具 举报

发表于 2020-11-18 16:34 | 显示全部楼层
看看
回复

使用道具 举报

发表于 2020-11-18 16:47 | 显示全部楼层
Option Explicit
Sub 数据替换()
    Dim rg As Range
    For Each rg In Selection
        If VBA.IsNumeric(rg.Value) And rg.Value > 0 Then
            rg.Value = "正数"
        End If
    Next rg
End Sub

Sub 一次选取()
    Dim rg As Range
    Dim rg2 As Range
    Dim i As Byte
    For Each rg In Range("A2:C12")
        If VBA.IsNumeric(rg.Value) And rg.Value > 0 Then
            If i = 0 Then
                Set rg2 = rg.EntireRow
                i = 1
            Else
                Set rg2 = Union(rg2, rg.EntireRow)
            End If
        End If
    Next rg
    rg2.Select
End Sub
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-7 20:25 , Processed in 0.268548 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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