Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multiple parameters 1

Status
Not open for further replies.

burtech

MIS
Jan 20, 2004
9
GB
Hi. I'm having trouble with passing parameters into a sub. I have a sub called 'Import'. I want to pass in two parameters: a filename prefix stored in a cell on the active worksheet, and a loop value so I can put an 'Imported' flag next to the cell where I picked up the prefix. Here is my button click sub...

Sub Import_Button_Click()
Dim i As Integer
For i = 1 To 27
Import(Range("C" & i + 4).Value, i+4)
Next
End Sub

...and my import sub...

Sub Import(AFilePrefix As String, loopCount As Integer)
'
' Import Macro
'

Dim sheetname As String

sheetname = ActiveWorkbook.Name

Application.ScreenUpdating = False

For i = 1 To 7
Windows(AFilePrefix & "Performance.xls").Activate
Sheets(dyArray(i)).Select
Range("A1:AE124").Select
Application.CutCopyMode = False
Selection.Copy
Windows(sheetname).Activate
Sheets(dyArray(i)).Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
For j = 1 To 124
Range("AF" & j).Value = dyArray(i)
Range("AG" & j).Value = j
Range("AH" & j).Value = "X"
Next j
Range("A1").Select
Next i

Sheets("Tools").Select
Range("C" & loopCount).Value = "Imported"

Range("A1").Select

Application.ScreenUpdating = True

End Sub

VB is telling me there is a syntax error in the line where I call 'Import'. I don't know where I'm going wrong. Can anyone help me?

Steve
 
Hi burtech,

Try without the parentheses ..

Code:
[blue]Import Range("C" & i + 4).Value, i+4[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Or, if you insist on parebtheses:
Call Import(Range("C" & i + 4).Value, i+4)


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top