Solved

error vba

Posted on 2016-08-02
3
35 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)
Comment Utility
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
Comment Utility
No follow up by the asker
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now