Solved

error vba

Posted on 2016-08-02
3
47 Views
Last Modified: 2016-08-22
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

0
Comment
Question by:camper12
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points (awarded by participants)
ID: 41739995
You are assigning a multiple cell array to a single cell which does not seem right

Meanwhile try
Sheets("simulations").Cells(2, ctr).Value = Sheets("Model").Range("AP42:AP1041").Value
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 41764171
No follow up by the asker
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question