+ Reply to Thread
Results 1 to 4 of 4

Refer to Elements in an array

  1. #1
    Derick
    Guest

    Refer to Elements in an array

    I have a dynamic array whcih would be redimed to hold
    values in 20 rows and four columns TestArray(1 to 20, 4)

    How can I refer to the array so that the contents of a row
    in the array be sent to the worksheet.
    For example Range("A1:D1") = TestArray(1,4)

    Derick

  2. #2
    Tom Ogilvy
    Guest

    Re: Refer to Elements in an array

    Sub AAYY()
    Dim varr As Variant
    varr = Worksheets("Sheet1").Range("M5:P25").Value
    Worksheets("Sheet2").Range("A1:D1").Value = Application.Index(varr, 1, 0)
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Derick" <[email protected]> wrote in message
    news:[email protected]...
    > I have a dynamic array whcih would be redimed to hold
    > values in 20 rows and four columns TestArray(1 to 20, 4)
    >
    > How can I refer to the array so that the contents of a row
    > in the array be sent to the worksheet.
    > For example Range("A1:D1") = TestArray(1,4)
    >
    > Derick




  3. #3
    Derick Hughes
    Guest

    Re: Refer to Elements in an array

    Thanks Tom,
    I am now trying to work further with the elements of the array.
    I am trying to count the number of instances a value occurs in the array
    with this statement. However it produces a run time error '424' Object
    required.
    countNum is declared as a variant.
    CountNum =
    Application.WorksheetFunction.CountIf(Application.WorksheetFunction.Inde
    x(varr, 1, 0), 1)


    Regards
    Dk

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

  4. #4
    Tom Ogilvy
    Guest

    Re: Refer to Elements in an array

    Countif/Sumif doesn't work with arrays, only ranges.
    --
    Regards,
    Tom Ogilvy

    "Derick Hughes" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Tom,
    > I am now trying to work further with the elements of the array.
    > I am trying to count the number of instances a value occurs in the array
    > with this statement. However it produces a run time error '424' Object
    > required.
    > countNum is declared as a variant.
    > CountNum =
    > Application.WorksheetFunction.CountIf(Application.WorksheetFunction.Inde
    > x(varr, 1, 0), 1)
    >
    >
    > Regards
    > Dk
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!




+ 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