Avatar of camper12
camper12
 asked on

error vba

Hi Experts,

PFB my code. I am getting an error on  Range(Sheets("simulations").Cells(2, ctr)).Value = Sheets("Model").Range("AP42:AP1041").Value.

Please suggest.

Thanks


Sub loopThrough()
Dim i, j, ctr As Integer
Dim r(0 To 4, 0 To 4) As Long
Dim r2(0 To 4, 0 To 4) As Long

ctr = 1
For i = 0 To 4
    For j = 0 To 4
    Range("Run").Value = ctr
    Calculate
     Src = Sheets("Model").Range("AP42:AP1041").Value
    Range(Sheets("simulations").Cells(2, ctr)).Value = Sheets("Model").Range("AP42:AP1041").Value
    r(i, j) = Range("c").Value
    r2(i, j) = Range("s").Value
    ctr = ctr + 1
    Next j
Next i

End Sub

Open in new window

Microsoft Excel

Avatar of undefined
Last Comment
Saqib Husain

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Saqib Husain

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Saqib Husain

No follow up by the asker
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck