Visual Studio Forum

Ask Question   UnAnswered
Home » Forum » Visual Studio       RSS Feeds

Visual Basic for Excel Range(Cells Errors

  Asked By: John    Date: Apr 11    Category: Visual Studio    Views: 1249

Not sure if I'm in the right Category for this question, but here goes.

A simple routine to populate an array from a worksheet.

Option Explicit
Dim myarray As Variant

Sub read_as_entire_()
'myarray = Worksheets("Sheet2").Range(Cells(1, 1), Cells(6, 1)).Value

myarray = Worksheets("Sheet2").Range("a1:a6").Value

'Sheet2.Range("b1:b6") = myarray

Sheet2.Range(Cells(1, 2), Cells(6, 2)) = myarray

End Sub

If I use the commented out lines I get a 1004 Runtime error.
If I run it as is, it works. I need the Cells method to reference other ranges.



No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Visual Basic for Excel Range(Cells Errors Or get search suggestion and latest updates.