+ Reply to Thread
Results 1 to 6 of 6

Moving range to array

  1. #1
    Charlie
    Guest

    Moving range to array

    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

  2. #2
    Bob Phillips
    Guest

    Re: Moving range to array

    Dim MyGrid()


    MyGrid = Range("B2:D5")

    works for me

    --
    HTH

    Bob Phillips

    "Charlie" <Charlie@discussions.microsoft.com> wrote in message
    news:D4442702-D23E-404F-B54D-96805342908D@microsoft.com...
    > 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




  3. #3
    Tushar Mehta
    Guest

    Re: Moving range to array

    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

    In article <D4442702-D23E-404F-B54D-96805342908D@microsoft.com>,
    Charlie@discussions.microsoft.com says...
    > 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
    >


  4. #4
    Jim Cone
    Guest

    Re: Moving range to array

    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



    "Charlie" <Charlie@discussions.microsoft.com> wrote in message
    news:D4442702-D23E-404F-B54D-96805342908D@microsoft.com...
    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

  5. #5
    Tom Ogilvy
    Guest

    Re: Moving range to array

    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

    --
    Regards,
    Tom Ogilvy


    "Jim Cone" <jim.coneXXX@rcn.comXXX> wrote in message
    news:eRv4HMMeFHA.3836@tk2msftngp13.phx.gbl...
    > 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
    >
    >
    >
    > "Charlie" <Charlie@discussions.microsoft.com> wrote in message
    > news:D4442702-D23E-404F-B54D-96805342908D@microsoft.com...
    > 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




  6. #6
    Charlie
    Guest

    Re: Moving range to array

    Thanks all, it was the array declaration that held me up.

    "Tom Ogilvy" wrote:

    > 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
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Jim Cone" <jim.coneXXX@rcn.comXXX> wrote in message
    > news:eRv4HMMeFHA.3836@tk2msftngp13.phx.gbl...
    > > 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
    > >
    > >
    > >
    > > "Charlie" <Charlie@discussions.microsoft.com> wrote in message
    > > news:D4442702-D23E-404F-B54D-96805342908D@microsoft.com...
    > > 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

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1