+ Reply to Thread
Results 1 to 3 of 3

tranfer array to range

  1. #1
    AD108
    Guest

    tranfer array to range

    Hello,

    Forgive me if this shows up twice. I neglected the subject line.

    I am trying to transfer a range to an array, then transfer the values back
    to a different range, based on a condition. My array is returning
    "subscript out of range" error. Thanks in advance for any help.

    Sub TransferData()
    Dim i As Integer
    Dim x()
    x = Range("AG3:AG398")
    For i = 0 To 397
    If IsEmpty(Cells(i + 3, 7)) Then
    Cells(i + 3, 7).Value = x ( i )
    End If
    Next i

    End Sub



  2. #2
    NickHK
    Guest

    Re: tranfer array to range

    Does this make sense for you ?
    Dim x As Variant

    x = Range("AG3:AG398").Value

    Debug.Print LBound(x, 1) & " to " & UBound(x, 1)
    Debug.Print LBound(x, 2) & " to " & UBound(x, 2)

    NickHK

    "AD108" <[email protected]> 撰寫於郵件新聞:%[email protected]...
    > Hello,
    >
    > Forgive me if this shows up twice. I neglected the subject line.
    >
    > I am trying to transfer a range to an array, then transfer the values back
    > to a different range, based on a condition. My array is returning
    > "subscript out of range" error. Thanks in advance for any help.
    >
    > Sub TransferData()
    > Dim i As Integer
    > Dim x()
    > x = Range("AG3:AG398")
    > For i = 0 To 397
    > If IsEmpty(Cells(i + 3, 7)) Then
    > Cells(i + 3, 7).Value = x ( i )
    > End If
    > Next i
    >
    > End Sub
    >
    >




  3. #3
    AD108
    Guest

    Re: tranfer array to range

    Yes, I've got it working now. Thanks very much

    "NickHK" <[email protected]> wrote in message news:[email protected]...
    > Does this make sense for you ?
    > Dim x As Variant
    >
    > x = Range("AG3:AG398").Value
    >
    > Debug.Print LBound(x, 1) & " to " & UBound(x, 1)
    > Debug.Print LBound(x, 2) & " to " & UBound(x, 2)
    >
    > NickHK
    >
    > "AD108" <[email protected]>

    撰寫於郵件新聞:%[email protected]...
    > > Hello,
    > >
    > > Forgive me if this shows up twice. I neglected the subject line.
    > >
    > > I am trying to transfer a range to an array, then transfer the values

    back
    > > to a different range, based on a condition. My array is returning
    > > "subscript out of range" error. Thanks in advance for any help.
    > >
    > > Sub TransferData()
    > > Dim i As Integer
    > > Dim x()
    > > x = Range("AG3:AG398")
    > > For i = 0 To 397
    > > If IsEmpty(Cells(i + 3, 7)) Then
    > > Cells(i + 3, 7).Value = x ( i )
    > > End If
    > > Next i
    > >
    > > End Sub
    > >
    > >

    >
    >




+ 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