+ Reply to Thread
Results 1 to 3 of 3

Format when sending a range as parameter to a custom function

  1. #1
    George Furnell
    Guest

    Format when sending a range as parameter to a custom function

    Hello,

    I created a custom functiom for which I need to send a range (A1:A5), that I
    will loop throu in my function.

    Please indicate what the funtion definition will looklike, ie how do I
    specify that it will receive a range in that format? I do have the code that
    will loop through the cells.

    Kind regards

    George

  2. #2
    Jim Thomlinson
    Guest

    RE: Format when sending a range as parameter to a custom function

    Something like this... (hard to tell from your question)

    Public Sub SendRange()
    Dim dblAmount As Double

    dblAmount = RecieveRange(Sheets("Sheet1").Range("A1:A5"))
    MsgBox "The total is " & dblAmount
    End Sub

    Public Function RecieveRange(ByVal MyRange As Range) As Double
    Dim rng As Range
    Dim dblTotal As Double

    For Each rng In MyRange
    dblTotal = dblTotal + rng.Value
    Next rng
    RecieveRange = dblTotal
    End Function

    --
    HTH...

    Jim Thomlinson


    "George Furnell" wrote:

    > Hello,
    >
    > I created a custom functiom for which I need to send a range (A1:A5), that I
    > will loop throu in my function.
    >
    > Please indicate what the funtion definition will looklike, ie how do I
    > specify that it will receive a range in that format? I do have the code that
    > will loop through the cells.
    >
    > Kind regards
    >
    > George


  3. #3
    George Furnell
    Guest

    RE: Format when sending a range as parameter to a custom function

    Thank you so much.
    Kind regards

    George

+ 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