Excel精英培训网

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

[已解决]如何定位最后的单元格

[复制链接]
发表于 2014-4-15 11:15 | 显示全部楼层 |阅读模式
本帖最后由 股网千王 于 2014-4-15 11:46 编辑

检查重复.zip (16.89 KB, 下载次数: 9)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2014-4-15 11:26 | 显示全部楼层
加个判断条件呢
If .CountIf(Range("A3:A" & lMaxRows), Cells(i, 1)) > 1 And Cells(i, 1) <> "" Then
回复

使用道具 举报

发表于 2014-4-15 11:35 | 显示全部楼层    本楼为最佳答案   
本帖最后由 lisachen 于 2014-4-15 11:36 编辑

复制代码
笨办法
Sub 查检重复项()
    Dim i As Long
    Dim lMaxRows As Long
    lMaxRows = Range("A65536").End(xlUp).Row
    For x = lMaxRows To 3 Step -1
   If Cells(x, 1) <> "" Then lMaxRows = x: Exit For
    Next x

        With Application.WorksheetFunction
            For i = 3 To lMaxRows
                If .CountIf(Range("A3:A" & lMaxRows), Cells(i, 1)) > 1 Then
                    MsgBox "该产品已经登记过了!", , "星语科技提示"
                End
                End If
            Next i
        End With
End Sub
回复

使用道具 举报

 楼主| 发表于 2014-4-15 11:45 | 显示全部楼层
as0810114 发表于 2014-4-15 11:26
加个判断条件呢
If .CountIf(Range("A3:A" & lMaxRows), Cells(i, 1)) > 1 And Cells(i, 1)  "" Then

多谢老师指教
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-16 19:22 , Processed in 0.358094 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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