Hello,
For a start you function
EEPosSheets
does not work. It will always throw an exception whatever the index is...
You need to move the extension inside the case statement:
Select Case Index
Case 1
EmpSheets = xlWSAllEEAnnul
PosSheets = xlWSAllPositionAnnul
Case 2
EmpSheets = xlWSAllEEHourly
PosSheets = xlWSAllPositionHourly
Case 3
EmpSheets = xlWSAllEESalary
PosSheets = xlWSAllPositionSalary
Case Else
Throw New ArgumentOutOfRangeException("Index")
End Select
Secondly your method expects 3 parameters
EEPosSheets(Index As Long, ByRef EmpSheets As Excel.Worksheet, ByRef PosSheets As Excel.Worksheet)
So when you call it you need to pass 3 parameters
EEPosSheets(i, sheet1, sheet2 )
Thirdly a function should return something (somthing is an object of some kind...)
Public Function EEPosSheets(Index As Long, ByRef EmpSheets As Excel.Worksheet, ByRef PosSheets As Excel.Worksheet) As something
otherwise use a sub
Public Sub EEPosSheets(Index As Long, ByRef EmpSheets As Excel.Worksheet, ByRef PosSheets As Excel.Worksheet)
Good luck.
Valery.