Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

error vba

Posted on 2016-08-02
3
48 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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