Excel精英培训网

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

[已解决]查找

[复制链接]
发表于 2012-11-29 10:37 | 显示全部楼层 |阅读模式
从T3到AA列不等于空的区域里查找<>0的单元格改变颜色,然后清除内容.
最佳答案
2012-11-29 14:31
Sub a()
    Dim an As Range
    For Each an In Range("t3:aa65536")
    If an <> 0 And an <> "" Then
    an.Interior.ColorIndex = 3
    an.ClearContents
    End If
    Next an
End Sub
最后一个单元格最简单的方法,对运算不会有什么影响

新建 Microsoft Office Excel 工作表.rar

17.62 KB, 下载次数: 9

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-11-29 11:18 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2012-11-29 11:24 | 显示全部楼层
从从容容 发表于 2012-11-29 11:18
这个也太简单呀。

我水平太菜了,帮我整一个,谢谢了
回复

使用道具 举报

发表于 2012-11-29 12:19 | 显示全部楼层
Sub a()
    Dim an As Range
    For Each an In Range("t3:aa146")
    If an <> 0 And an <> "" Then
    an.Interior.ColorIndex = 3
    an.ClearContents
    End If
    Next an
End Sub

评分

参与人数 1 +3 收起 理由
hvail + 3

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-11-29 13:02 | 显示全部楼层
我心永恒 发表于 2012-11-29 12:19
Sub a()
    Dim an As Range
    For Each an In Range("t3:aa146")

For Each an In Range("t3:aa146")能把AA146改成不固定的吗,因为AA146会不断的变
回复

使用道具 举报

 楼主| 发表于 2012-11-29 13:25 | 显示全部楼层
我心永恒 发表于 2012-11-29 12:19
Sub a()
    Dim an As Range
    For Each an In Range("t3:aa146")

老师帮我改改嘛!谢谢了
回复

使用道具 举报

 楼主| 发表于 2012-11-29 13:35 | 显示全部楼层
我心永恒 发表于 2012-11-29 12:19
Sub a()
    Dim an As Range
    For Each an In Range("t3:aa146")

大哥!我等着设最佳你的呀
回复

使用道具 举报

发表于 2012-11-29 13:44 | 显示全部楼层
你里面没有看到有值为 0  的单元格嘛

  1. Sub 宏1()
  2.   With Cells.SpecialCells(xlCellTypeConstants, 1)
  3.     .Interior.ColorIndex = 9
  4.     .ClearContents
  5.   End With
  6. End Sub
复制代码

评分

参与人数 1 +3 收起 理由
hvail + 3

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-11-29 13:51 | 显示全部楼层
无聊的疯子 发表于 2012-11-29 13:44
你里面没有看到有值为 0  的单元格嘛

大师你好,是有0的,还有是区域是在T3开始
回复

使用道具 举报

发表于 2012-11-29 13:54 | 显示全部楼层
如果有可能有 0  的单元格,就用下面的方法

  1. Sub 宏1()
  2.   If Not Cells.Find(0, , , 1) Is Nothing Then Cells.Replace 0, "", 1
  3.   With Cells.SpecialCells(xlCellTypeConstants, 1)
  4.     .Interior.ColorIndex = 33
  5.     .ClearContents
  6.   End With
  7. End Sub
复制代码
如果要保留原来那个 0 可以换一下

  1. Sub 宏1()
  2.   If Not Cells.Find(0, , , 1) Is Nothing Then Cells.Replace 0, "A0", 1
  3.   With Cells.SpecialCells(xlCellTypeConstants, 1)
  4.     .Interior.ColorIndex = 33
  5.     .ClearContents
  6.   End With
  7.   If Not Cells.Find("A0", , , 1) Is Nothing Then Cells.Replace "A0", 0, 1
  8. End Sub
复制代码

评分

参与人数 1 +3 收起 理由
hvail + 3

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-29 11:46 , Processed in 1.164621 second(s), 16 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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