Excel精英培训网

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

[已解决]不能区分大小写

[复制链接]
发表于 2014-1-5 10:25 | 显示全部楼层 |阅读模式
本帖最后由 张雄友 于 2014-1-5 13:07 编辑

不能区分大小写?
  1. Private Sub Worksheet_Change(ByVal Target As Range) '不能区分大小写的?如输入小写f,都说重复,怎么修改可以区分大小写???
  2. If Target.Column = 1 Then
  3.   If Target.Value <> "" And Application.CountIf(Columns(1), Target.Value) > 1 Then
  4.     MsgBox "请不要重复录入"
  5.     Application.Undo
  6.    End If
  7. End If
  8. End Sub

复制代码
最佳答案
2014-1-5 11:02
只改了内层条件,外面的没管
If Target.Value <> "" Then
     Application.EnableEvents = 0
     tmp = Target.Value
     Target = ""
     If Range("A:A").Find(tmp, , , , , , 1) Is Nothing Then
         Target = tmp
    Else
         MsgBox "请不要重复录入"
         Application.Undo
    End If
    Application.EnableEvents = 1
   End If

控制重复录入.rar

6.75 KB, 下载次数: 17

发表于 2014-1-5 10:38 | 显示全部楼层
用find吧。countif本来就不区分大小写
回复

使用道具 举报

 楼主| 发表于 2014-1-5 10:46 | 显示全部楼层
上清宫主 发表于 2014-1-5 10:38
用find吧。countif本来就不区分大小写

宫主明示,不会。
回复

使用道具 举报

发表于 2014-1-5 11:02 | 显示全部楼层    本楼为最佳答案   
只改了内层条件,外面的没管
If Target.Value <> "" Then
     Application.EnableEvents = 0
     tmp = Target.Value
     Target = ""
     If Range("A:A").Find(tmp, , , , , , 1) Is Nothing Then
         Target = tmp
    Else
         MsgBox "请不要重复录入"
         Application.Undo
    End If
    Application.EnableEvents = 1
   End If
回复

使用道具 举报

发表于 2014-1-5 11:54 | 显示全部楼层
还可以这样:

控制重复录入.rar (8.74 KB, 下载次数: 10)

评分

参与人数 1 +3 收起 理由
张雄友 + 3 很给力!也很好的!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-29 16:03 , Processed in 0.295402 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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