Consulting

Results 1 to 2 of 2

Thread: Solved: How to refer to a range?

  1. #1

    Solved: How to refer to a range?

    In excel 2010 I would like to be able to make a function which can refer to any amount of cells. By this I mean in the same way as the sum or average function do, for any selection I choose.

    I hope that makes sense. Can anyone help with this?

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Function myFunc(rng As Range) As Double
    Dim cell As Range
    dim tmp As Double

    For Each cell in rng

    tmp = tmp + cell.Value2
    Next cell

    myFunc = tmp
    End Function
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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