首页 > 解决方案 > VBA 最后一行命令

问题描述

我正在 VBA 中创建一个 VLOOKUP,它工作正常,但我无法仅将 A 列中包含值的单元格定义为“范围”。下面的行考虑了所有列 A 及其给我列中所有空单元格的错误消息。知道如何修复语法吗?

   Set lookFor = book1.Sheets(1).Range("A3" & LastRow)

标签: vbaexcel

解决方案


使用 SpecialCells 定位文本和数字常量。

Set lookFor = book1.Sheets(1).Range("A1:A" & LastRow).SpecialCells(xlCellTypeConstants, xlNumbers+xlTextValues)

推荐阅读