Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Functions that return a Range

To put the quetion simple: Is it possible to design Excel Funtions similar
to the MMULT function using exclusively VBA.

Thank you for any help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Functions that return a Range

This is an example of a function that takes an input and creates an array of
output cells, it should get you started

Function myFunction(inDate As Date, inType As String) As Variant
Dim nextDate As Date
Dim i As Long
Dim cCells As Long
Dim tmpArray() As Date

nextDate = inDate
cCells = Application.Caller.Cells.Count
ReDim Preserve tmpArray(0 To cCells)
For i = 1 To cCells
tmpArray(i - 1) = nextDate
Select Case LCase(inType)
Case "day": nextDate = nextDate + 1
Case "week": nextDate = nextDate + 7
Case "month": nextDate = nextDate + 30
Case "year": nextDate = nextDate + 365
End Select
Next i

If Application.Caller.Rows.Count = 1 Then
myFunction = tmpArray
Else
myFunction = Application.Transpose(tmpArray)
End If

End Function



--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"MLMeneses" wrote in message
...
To put the quetion simple: Is it possible to design Excel Funtions similar
to the MMULT function using exclusively VBA.

Thank you for any help




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return date if in range, else return blank LisaL Excel Worksheet Functions 1 July 22nd 09 03:23 PM
Match and return functions LiAD Excel Worksheet Functions 14 September 5th 08 01:49 PM
MIN and IF functions return no value if there is no date [email protected] Excel Worksheet Functions 4 April 25th 08 04:24 AM
How to return value from functions in other sheets? TR Excel Worksheet Functions 3 October 23rd 06 08:25 PM
Return two mid functions as one string. Keith Lorenzen Excel Programming 6 October 9th 03 02:46 PM


All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"