Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Return Array from Function

I have the following function that works fine, unless I add arguements.
When I add the arguments I get a Run-Time error '13': Type mismatch.
Any help would be greatly appreciated.

Option Base 1
Function FileSearch(Directory As String, Criteria As String)

Dim aFiles()


With Application.FileSearch

.NewSearch
.LookIn = Directory 'ActiveWorkbook.Worksheets("Control").Cells(3,
2) 'Directory
.SearchSubFolders = True
.Filename = Criteria '
ActiveWorkbook.Worksheets("Control").Cells(4, 2) 'Criteria
.Execute

ReDim aFiles(.FoundFiles.Count)

For i = LBound(aFiles) To UBound(aFiles)
aFiles(i) = .FoundFiles(i)
Debug.Print i, aFiles(i)
Next i

End With

'FileSearch = Application.WorksheetFunction.Transpose(aFiles)
FileSearch = aFiles
End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Return Array from Function

Gary,

Thank you worked like a charm. I will be sure not to use reserved
words in the future.

Thanks again,

John

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
Reverse a function to return the array? bc4240 Excel Worksheet Functions 4 July 31st 09 05:25 AM
Which Function to Use? Search an Array, Return a Row Value [email protected] Excel Discussion (Misc queries) 1 August 24th 07 06:34 PM
Using INDEX function to return array row. RBI Excel Worksheet Functions 1 October 4th 06 03:21 PM
Return array from worksheet function Steve Lloyd Excel Worksheet Functions 4 July 19th 06 06:15 PM
Return an array of values from a function Raul Excel Programming 6 December 13th 04 07:33 PM


All times are GMT +1. The time now is 03:21 AM.

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

About Us

"It's about Microsoft Excel"