我想从不同的范围中读取,其中有些值通过这些单元格中的某些公式计算,在VBA中,并使用已保存的值覆盖这些范围,以便自动删除单元格中的公式
代码如下:
allValues = Range("AR8:AW8,AR10:AW10,AR12:AW24,AR26:AW52,AR54:AW61,AR64:AW87,AR89:AW94,AR96:AW96,AR98:AW104,AR106:AW106,AR108:AW110,AR112:AW122,AR125:AW140,AR142:AW162,AR164:AW192,AR194:AW196,AR198:AW198,AR200:AW202,AR204:AW218,AR220:AW230,AR232:AW232,AR234:AW240").Value
Range("AR8:AW8,AR10:AW10,AR12:AW24,AR26:AW52,AR54:AW61,AR64:AW87,AR89:AW94,AR96:AW96,AR98:AW104,AR106:AW106,AR108:AW110,AR112:AW122,AR125:AW140,AR142:AW162,AR164:AW192,AR194:AW196,AR198:AW198,AR200:AW202,AR204:AW218,AR220:AW230,AR232:AW232,AR234:AW240")= allValues
对于联合范围这样的想法已经解决了,但对于这些想法根本没有。
我感谢任何意见。
答案 0 :(得分:1)
使用多区域范围,迭代区域:
Dim r As Range
For Each r In Sheet1.Range("AR8:AW8, AR10:AW10, ..., ...").Areas
r.Value = r.Value
Next
答案 1 :(得分:0)
我会像下面这样说:
With Range("AR8:AW8,AR10:AW10,AR12:AW24,AR26:AW52,AR54:AW61,AR64:AW87,AR89:AW94,AR96:AW96,AR98:AW104,AR106:AW106,AR108:AW110,AR112:AW122,AR125:AW140,AR142:AW162,AR164:AW192,AR194:AW196,AR198:AW198,AR200:AW202,AR204:AW218,AR220:AW230,AR232:AW232,AR234:AW240")
.Value = .Value
End With