Hi Cyberuser :) 1) why pass _wk1 (or is _ supposed to be a line continuation and its wks1)? You don't refer to wks1 in your procedure.
2) what do you mean -- how can you change it to... -- it looks to me like what you want to change it to is exactly the procedure declaration you're already using... (?) 3) yes, call is optional. There are two (main) ways to call sub procedures: a. ProcedureName param1, param2, param3... b. Call ProcedureName (param1, param2, param3...) Basically, omit the parenthesis if you omit the Call statement. I don't use Call. Function procedures on the other hand are designed to return values. If you call a function procedure using the Call statement, you can't use the return value, kind of defeating the purpose. To call a function, just use it as part of an expression. For example: a. Set myrange = BellyDance(. . . . .) b. Range("A1").Value = BellyDance(. . .).Cells(2,3).Address Asa -----Original Message----- From: excel-macros@googlegroups.com [mailto:excel-macros@googlegroups.com] On Behalf Of bpascal123 Sent: Friday, March 09, 2012 11:45 AM To: MS EXCEL AND VBA MACROS Subject: $$Excel-Macros$$ how to make a sub with arrays parameters Hi cyberspace, In a previous code, I wanted to implement a routine within a sub that would perform the last part of the code : Private Function BellyDance(ByRef ArrX() As String, ByRef ArrY() As String, _wks1 As Worksheet, wks2 As Worksheet, wks3 As Worksheet) Dim rg As range Dim i As Long, j As Long Dim r As Long 'rg.Value = "ok" r = 2 For i = 0 To UBound(ArrX, 1) For j = 0 To UBound(ArrY, 1) If UCase(ArrY(j, 1)) = UCase(ArrX(i, 1)) Then wks2.Rows(ArrY(j, 0)).Copy wks3.Rows(r) r = r + 1 End If Next j Next i Set rg = wks3.range("A1").CurrentRegion Set BellyDance = rg End Function How can I change this to : Sub BellyDance(ByRef ArrX() As String, ByRef ArrY() As String, _wks1 As Worksheet, wks2 As Worksheet, wks3 As Worksheet) and the syntax for the calling part as it seems "call" is optional when calling a sub, sometimes I see ... call name_of_the_sub ...and sometimes i can just see ... name_of_the_sub ... Is there any difference? I know how to call sub without parameters and sometimes with parameters but for this code above, it wouldn't work, error at the line of the call. Any idea? Cyberuser, -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ---------------------------------------------------------------------------- -------------------------- To post to this group, send email to <mailto:excel-macros@googlegroups.com> excel-macros@googlegroups.com -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com