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
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