Results 1 to 4 of 4

Using array constants in user-defined excel vba function

Threaded View

  1. #1
    Registered User
    Join Date
    10-01-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Using array constants in user-defined excel vba function

    I have a function in VBA of the type

    Function MyFunc(Indx As Integer, k As Long, Rho As Range, A As Range) As Variant .... End Function

    which is called as a user-defined function from within the Excel worksheet. When called with the last two arguments being a range (i.e. Result = MyFunc(1,98,A1:A2, B1:B2)) it works fine. However, when I try to directly use an array constant instead of a range (i.e. Result = MyFunc(1,98,{10,11}, {20,30}), it returns a #VALUE error.

    I thought I could fix it by redefining the last two arguments as arrays of type double, but this didn't work either (i.e. Function MyFunc(Indx As Integer, k As Long, Rho() As Double, A() As Double) As Variant .... End Function ).

    Does someone have a suggestion for a flexible solution, which would permit either calling method: by range, as well as by an array constant?

    Thanks in advance!
    Last edited by MiloMan; 10-01-2009 at 08:58 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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