0

I am just starting out with VBA, so I don't know a lot about it. I've made an Monte Carlo Simulation with VBA (just a for-loop to compute a formula) and now I want to get every value from that for-loop and print it out under each other in the excel worksheet.

I thought about storing every value after the for-loop in an array and printing it out, but I got really stuck in the process. Is an array the best method for this or can it be done easier?

My code is something like this:

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

Thank you very much guys! If you need the real source I can always paste it here.

Community
  • 1
  • 1
Motta23
  • 77
  • 5

1 Answers1

0

To show information in the Immediate window in the VB editor (Ctrl+G)...

Debug.Print *some value here*

citizenkong
  • 679
  • 5
  • 14
  • Thank you very much, but I actually don't know what I can do with this other than checking the VB editor out. Is there a way that I can store the values in my case from a for loop? – Motta23 Aug 15 '14 at 15:44
  • Sure, you could store them in an array, or even just write them to a Worksheet as you go. – citizenkong Aug 15 '14 at 15:48
  • And how would you do it if you would write them to a worksheet? Do you mean with the debug.print. Could be a problem for my pc as I would like to run a lot of simulations (or would I get the same problems if I would choose to use an array)? Thank you :) – Motta23 Aug 15 '14 at 16:06