gpt4 book ai didi

excel - "Method ' 范围 ' of object ' _Worksheet ' failed"错误消息

转载 作者:行者123 更新时间:2023-12-02 19:38:20 24 4
gpt4 key购买 nike

我已经尝试了底部链接的问题中建议的代码,但出现错误:

Set getNthColumn = Range(startCell, endCell)

错误是

Method 'Range' of object '_Worksheet' failed

此代码应该设置公式为 VLOOKUP 的范围单元格的颜色格式。

感谢所有帮助。

Vlookup to copy color of a cell - Excel VBA

最佳答案

显然您将代码放入工作表的代码模块中。

在这种情况下,Range() 解析为该工作表的 Worksheet.Range()。如果 startCellendCell 属于不同的工作表,您将收到错误。

如果将代码放在普通模块中,如OP specifically requestedRange() 就意味着 Application.Range(),这将正确构建您的范围。

您可以通过显式使用 Application.Range(startCell, endCell) 来消除这种歧义。

关于excel - "Method ' 范围 ' of object ' _Worksheet ' failed"错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33614533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com