Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将变量传递给 ActiveSheet.Range ?示例而不是硬编码为 With ActiveSheet.Range("C2:H15"),现在我想将 C2 和 H15 替换为变量,我尝试了如下代码,但它似乎不起作用
With ActiveSheet.Range("StarRange:EndRange")
假设您已将这些定义为:
Dim StarRange as String Dim EndRange as String
StarRange 是“C2”,EndRange 是“H15”,那么简单地说:
With ActiveSheet.Range(StarRange & ":" & EndRange)