Results 1 to 4 of 4

Combine - by summing - two arrays into a third

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Combine - by summing - two arrays into a third

    Hi,

    I know a few ways to accomplish the task but I'm curious to know if there is a syntax which will "Do it My Way".
    The following code will fill Arr1 cells with 10 values from range A1:A10 and then fill F1:F10 with those values.

    Sub FODA()                
      Dim Rng As Range
      Arr1 = Range("A1:A10")
      Set Rng = Range("F1:F10")
      Rng = Arr1
    End Sub

    Now, assume 2 ranges (A1:A10 and B1:B10)
    Putting each range into an Array is easy - as shown in the 2 first commands of the following code.

    I want to add cell 1 of Arr1 with cell 1 of Arr2 and put the result in cell 1 of Arr3
    I have tried:

    Sub FODA2()
    Dim Rng As Range
      Arr1 = Range("A1:A10")
      Arr2 = Range("B1:B10")
      Arr3 = Arr1 + Arr2    ' Returns "Type Mismatch" error
      Set Rng = Range("F1:F10")
      Rng = Arr3
    End Sub

    Is there a way to fill Arr3 with Arr1 & Arr2 cells sum with a single command (WITHOUT LOOPING) ?.

    'Join' and 'Split' don't seem to do any good.

    Thanks, Elm
    Last edited by ElmerS; 03-25-2010 at 03:34 AM.

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