0

My aim is to run Arena simulation via Excel VBA and get results of simulation to Excel. I wrote some codes.

As you can see, my codes start Arena simulation. And parameter "j" holds the solution of simulation. What I want is that write down all replications result. For example, j1 (result of first replication), j2, j3 ... etc. How can I do that?

Sub Test()

Dim oArenaApp As Arena.Application
Dim oModel As Arena.Model, oSIMAN As Arena.SIMAN
Dim oModule As Arena.Module

Set oArenaApp = CreateObject("Arena.application")
ModName = "D:\Model2.doe"
Set oModel = oArenaApp.Models.Open(ModName)
Set oSIMAN = oModel.SIMAN
oArenaApp.Activate
oArenaApp.Visible = True

oModel.BatchMode = True
oModel.QuietMode = True
oModel.Go (smGoWait)

i = oSIMAN.SymbolNumber("Entity 1")
j = oSIMAN.EntitiesNumberOutOfType(i)

oModel.End
oArenaApp.Visible = False

End Sub
  • I assume you're running this code from Excel? If so, you could e.g. do the following: Worksheets("results").Range("A2").Value = i And Worksheets("results").Range("B2").Value = j Do you have to run your model multiple times to get the j2, j3 etc? – Koen Rijnsent Feb 24 '20 at 10:14
  • Yes I am running this code from Excel. I dont want to run model multiple times. I need proper library object to get every replication result. Arena simulation has library in VBA. But I cannot get every replication output. –  Feb 24 '20 at 10:54

1 Answers1

0

If you include VBA in your Arena model, it can read and write an Excel workbook. Arena has "Smart Files Library" which are essentially tutorials.

You may find some value from "VBA Reading Writing Excel Using VBA Module.doe: Reading and writing to Excel using the VBA module"

John
  • 6,701
  • 3
  • 34
  • 56