excel - 为什么VB在遍历集合时抛出
问题描述
我收到以下代码的“对象变量或未设置块变量”。
Set entries = FindAllMatches(interestWorksheets, input_chapter_code)
For Each x In entries
If x.Value = input_amount.Value Then // VBA STOPS HERE
End if
Next
调试器显示entries
有 4 个Range
元素,而x
is Nothing
(WHAT???)
FindAllMatches
定义如下:
Function FindAllMatches(worksheets, input_chapter_code) As Collection
Dim list As New Collection
For Each ws In worksheets
list.Add Item:=FindMatchInWorksheet(ws, input_chapter_code)
Next
Set FindAllMatches= list
End Function
Function FindMatchInWorksheet(worksheet, input_chapter_code) As Range
...
End Function
解决方案
推荐阅读
- javascript - 拖放中的中断跨度
- angular - 角等待订阅完成然后返回
- php - 无法运行 php artisan schedule:run 命令
- python - 每天转换数据框行中给定的每个日期范围的数据
- laravel - Laravel 测试文件上传和调整大小
- database - 从 rabbitMQ 发送消息到 PostgreSQL
- python - Initialising an array using different array
- c# - 在 C# 程序中获取 MFA 信息
- google-sheets - 带有日期范围和唯一 ID 条件的 IMPORTRANGE 的 COUNTIF
- ffmpeg - 从 mxf 到 mp4 的 Nvidia Nvenc 视频转换在内部的多个流中出现错误