Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 在数组中存储和打印值-VBA_Arrays_Vba_Excel - Fatal编程技术网

Arrays 在数组中存储和打印值-VBA

Arrays 在数组中存储和打印值-VBA,arrays,vba,excel,Arrays,Vba,Excel,我刚开始学习VBA,所以我对它了解不多。我用VBA做了一个Monte Carlo模拟,只是一个for循环来计算一个公式,现在我想从for循环中得到每个值,并在excel工作表中打印出来 我曾想过将for循环之后的每个值存储在一个数组中并打印出来,但我在这个过程中遇到了麻烦。数组是实现这一点的最佳方法,还是可以更容易地实现 我的代码是这样的: for i = 1 to numberofclients for j = 1 to numberofsimulations -->my form

我刚开始学习VBA,所以我对它了解不多。我用VBA做了一个Monte Carlo模拟,只是一个for循环来计算一个公式,现在我想从for循环中得到每个值,并在excel工作表中打印出来

我曾想过将for循环之后的每个值存储在一个数组中并打印出来,但我在这个过程中遇到了麻烦。数组是实现这一点的最佳方法,还是可以更容易地实现

我的代码是这样的:

for i = 1 to numberofclients
for j = 1 to numberofsimulations
   -->my formula to compute the value I want to print
Next j
---> It would be ideal that after every set of simulations the value could be printed under each other
Next i

非常感谢大家!如果您需要真实的源代码,我可以将其粘贴到此处。

要在VB编辑器的即时窗口中显示信息,请按Ctrl+G


Debug.Print*此处有一些值*

非常感谢,但实际上,除了检查VB编辑器之外,我不知道我能做些什么。有没有一种方法可以从for循环存储案例中的值?当然,您可以将它们存储在数组中,甚至可以在运行时将它们写入工作表。如果您将它们写入工作表,您将如何操作?你是说用debug.print吗。可能是我的电脑的一个问题,因为我想运行很多模拟,或者如果我选择使用阵列,我会遇到同样的问题吗?谢谢您: