提问人:Josh Marks 提问时间:11/15/2023 最后编辑:IkeJosh Marks 更新时间:11/15/2023 访问量:43
Excel VBA:通过隐藏值搜索异常行为
Excel VBA: Unusual behavior searching through hidden values
问:
当我调用此代码时,foundCell 没有返回任何内容,而 rows40-82 是隐藏的。我希望它返回 cells(74, “B”)。
参数:
- ws = rev-loc 选项卡,有效条目
- 行 = 77
- actName = “4100 ·每名学生 设施分配”
在即时窗口中:
- actString => 每名学生设施分配”
- actString = ws.cells(74, “B”) => 真
Private Function GetAccountRange(ws As Worksheet, actName As String, row As Long) As Range
Dim rowStart As Long, rowEnd As Long, colEnd As Long, actString As String
Dim foundCell As Range
actString = Right(actName, Len(actName) - InStr(actName, " " & Chr(183) & " ") - 2)
Set foundCell = ws.Columns("B").Find(actString, after:=ws.Cells(row, "B"), LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False, SearchDirection:=xlPrevious)
它应该返回 cells(74, “B”)。选择:
- 当我在行 40-82 可见的情况下运行该函数时,它的行为符合我的预期
- 当我运行在第 73 行而不是第 74 行中传递的函数时,它的行为符合我的预期
提前致谢! 乔希
答: 暂无答案
评论
Application.WorksheetFunction.Match
Find
SearchDirection:=xlNext
SearchDirection:=xlPrevious
ws.Cells(row, "B")