Sub RangeToVariant2()
    'This works fine on its own. Basically subtracts A1 - A2 - A3...
    Dim x As Variant
    Dim r As Long, c As Integer

'   Read the data into the variant
    x = Range("A1:A20").Value

'   Loop through the variant array
    For r = 1 To UBound(x, 1) - 1
        For c = 1 To UBound(x, 2)
            'subtraction the numbers
            x(r + 1, c) = x(r, c) - x(r + 1, c)

        Next c
    Next r

'   Transfer the variant back to the sheet
    Range("C1:C20") = x
End Sub

On Feb 27, 9:43 pm, DeveloperMichael <mikei...@gmail.com> wrote:
> What is a common technique to perform subtraction on a variable size
> array?

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to