Hello,
I'm trying to run this code ( see below), but I get the following error message: Compile Error Invalid Next Control Variable Reference.
The variable "Fila" at the end is highlighted: "File:83 to 82" .
Thanks for your help.
I'm trying to run this code ( see below), but I get the following error message: Compile Error Invalid Next Control Variable Reference.
The variable "Fila" at the end is highlighted: "File:83 to 82" .
Thanks for your help.
Code:
Sub Run()
Dim Celda1 As String
Dim p10, p50, p90, NumIter As Single
Dim Fila, V, S, I1, I2, I3, J3, J4, J5 As Integer
Sheets("Main").Select
NumIter = Sheets("Main").Cells(3, 3).Value
S = 1 ' Scenario Number
I1 = 1 ' Define I1 as first I for each scenario
I2 = 1 ' Define I2 as last I for each scenario
V = 2 ' First Fila Number
I3 = 1
J3 = 2
J5 = 2
For S = 1 To 24
If Worksheets("main").Cells(5 + S, 16).Value = "Yes" Then
Worksheets("Economics").Range("Z2").Value = S
Sheets("Random Count").Select
For i = 1 To NumIter
Sheets("Random Count").Cells(1, J3).Value = S & "_" & i
Sheets("Main").Select
Range("D7").Select
For Each Cell In Range("D7:D65") 'i.e. each variable to be ramdomized
Celda1 = ActiveCell
Select Case Celda1
Case "Uniform"
Call Uniforme
Case "Triangular"
Call Triangular
Case "Normal"
Call Normal
Case "LogNormal"
Call LogNormal
Case "UniformInteger"
Call UniformInteger
Case ""
ActiveCell.Offset(1, 0).Select
End Select
Next Cell
'If Range("L28") = "N" Then
'Call CalculoOOIP
'Else
'End If
' Ramdon Numbers in "Main" in Range(B7:B67)
' Main Economic KPI's in "Economics" Range("D2:Y2")
' Oil, Water, Gas, WI, GI, Revenue Profiles in in "Economics" Range("D3:I34")
Fila = 2
For t = 1 To 60: Sheets("Random Count").Cells(Fila, (J3)).Value = Sheets("Main").Cells(t + 6, 3): Fila = Fila + 1: Next t
For t = 1 To 22: Sheets("Random Count").Cells(Fila, (J3)).Value = Sheets("Economics").Cells(2, Fila - 57): Fila = Fila + 1: Next t
For Fila = 83 To 82: Sheets("Random Count").Cells(Fila, (J3)).Value = Sheets("Economics").Cells(2, Fila - 57): Fila = Fila + 1: Next t