View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Michael[_27_] Michael[_27_] is offline
external usenet poster
 
Posts: 41
Default Question to a VBA Wizard!?

Hi,

I have below a piece of VBA code. Everytime the whole code is run, one
Excel worksheet named "Constraint" is frozen before "Model.Solve" is
called and de-frozen after that within the "JobNr" loop; using
".EnableCalculation".

The worksheet, "Constraint", has one cell with RAND() in it.


The problem I am getting is described next to the "For JobNr" row
loop:


Dim JobNr As Integer
For JobNr = a To a 'I mean here 1 To 1, 3 To 3,....once at a time
'it works fine
1 To 5 'However, it keeps repeating same reults each
time as
'if EnableCalculation is NOT working!

Range("B7").Value = JobNr

Workbooks(filename).Worksheets("Constraint").Enabl eCalculation = False
vehicleModel.Solve

line = 1

For Each mac In vehicleModel.Macros
rngSolution(JobNr, line).Value = mac.Value
line = line + 1
Next mac
Workbooks(filename).Worksheets("Constraint").Enabl eCalculation = True
Next JobNr


What should I do to fix this?

Thanks,
Mike