Moving range to array

G

Guest

Hi,

I can move a 2D array to a range but how do I move a selected range to a 2D
array?

Dim MyGrid() As String

Range("A9").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
MyGrid = Selection.Text

(or)

MyGrid = Range("B2:D5").Text

Thanks
 
T

Tushar Mehta

What problem are you having?

If it is type mismatch, use .Value instead of .Text and replace 'As
String' with 'As Variant'.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
J

Jim Cone

Charlie,

To add to Bob's post...
You cannot assign to an array in Excel 97.
In later versions you must use the Value property of the
range not the Text property, so...
MyGrid= Range("B2:D5").Value

Jim Cone
San Francisco, USA



Hi,
I can move a 2D array to a range but how do I move a selected range to a 2D
array?
Dim MyGrid() As String
Range("A9").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
MyGrid = Selection.Text
(or)
MyGrid = Range("B2:D5").Text
Thanks
 
T

Tom Ogilvy

Dim MyGrid as Variant
MyGrid= Range("B2:D5").Value

works fine for me in Excel 97.

Dim MyGrid() as Variant
MyGrid= Range("B2:D5").Value

doesn't work in Excel 97, VBA5
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top