我的代码中有一个错误(我找到了解决方法),但我希望您能帮助我确定问题所在。这是不起作用的代码:
Sub replacewithnumbers1()
Dim ReplacementRange As Range
Set ReplacementRange = Range("a2:c2")
Set ReplacementRange = Range(ReplacementRange, ReplacementRange.End(xlDown))
ReplacementRange.value = ReplacementRange.value
End Sub
当我运行它时,它适用于 A2:C17,但下面的所有内容都更改为“#N/A”。
现在这里是有效的代码:
Dim ReplacementRange As Range
Set ReplacementRange = Range("A2")
Set ReplacementRange = Range(ReplacementRange, ReplacementRange.End(xlDown))
ReplacementRange.value = ReplacementRange.value
Set ReplacementRange = Range("b2")
Set ReplacementRange = Range(ReplacementRange, ReplacementRange.End(xlDown))
ReplacementRange.value = ReplacementRange.value
Set ReplacementRange = Range("c2")
Set ReplacementRange = Range(ReplacementRange, ReplacementRange.End(xlDown))
ReplacementRange.value = ReplacementRange.value
Set ReplacementRange = Range("I2")
Set ReplacementRange = Range(ReplacementRange, ReplacementRange.End(xlDown))
ReplacementRange.value = ReplacementRange.value
我所做的只是把它分解成更多的步骤(每列一个),然后它就可以工作了。当我一次做两列时,我得到相同的错误(A:B 或 B:C)。它总是停在第 17 行,我不知道为什么。愿意帮助我吗?
谢谢!