热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

ExcelVBA查找列"C"包含已知值的最后一个行编号

如何解决《ExcelVBA查找列"C"包含已知值的最后一个行编号》经验,为你挑选了1个好方法。

在Excel VBA中查找方法以查找列"C"包含已知值的最后一个行号.



1> Gary's Stude..:

这将在C列中找到最后一次幸福

Sub SeekHappiness()
    Dim C As Range, where As Range, whatt As String
    whatt = "happiness"
    Set C = Range("C:C")
    Set where = C.Find(what:=whatt, after:=C(1), searchdirection:=xlPrevious)
    MsgBox where.Address(0, 0)
End Sub

要仅输出行号,请使用:

MsgBox Mid(where.Address(0, 0), 2)

要找到第一个匹配项:

Sub SeekHappiness()
    Dim C As Range, where As Range, whatt As String
    whatt = "happiness"
    Set C = Range("C:C")
    Set where = C.Find(what:=whatt, after:=C(1))
    MsgBox where.Address(0, 0)
End Sub


推荐阅读
author-avatar
行者05965
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有