如何添加阵列? [英] How to add arrays?

查看:158
本文介绍了如何添加阵列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel中存在如下问题通过一个循环计算时:
我需要一个变量(目标变量),该顺序存储产生的每个循环已经完成后(避免了使用循环引用的),这将是这样的结果:

I have the following problem in Excel while calculating through a loop: I need a variable (Destination Variable) that sequentially stores the results produced after each loop has been completed (avoiding the use of circular references) that would look like this:

'Let's call it "origin" variable in the worksheet
Origin Variable (50 x 50 array)
      1 2 4
      2 3 4
      2 2 3
'Let's call it "destination" variable in the worksheet
Destination Variable (50 x 50 array)
      1 1 1
      1 1 1
      1 1 1

每个循环后,我需要在宏执行以下code:

After each loop, I'd need the macro to perform the following code:

range("destination").value = range("destination").value + range("origin").value 

这样的目标变量应该是这样的电流回路后:

So that the destination variable would look like this after the current loop:

Destination Variable
      2 3 5
      3 4 5
      3 3 4

但是,Excel不允许我执行previous功能。结果
有没有人有答案如何可以解决?结果

However, Excel does not allow me to perform the previous function.
Does anyone have an answer how this could be solved?

推荐答案

很容易。我通过记录作为宏观和整理这样做。

Quite easy. I did this by recording as macro and tidying.

Sub Macro1()            
    Range("origin").Copy
    Range("destination").PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
End Sub

这篇关于如何添加阵列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆