arraytype is an argument in the function. If argument is staffcost i want myarray which is an array i created to contain staffcost values(Range"A93:M192"). If argument is general, i want myarray to store general value Range("A191:M222"). However i have an error saying that compile error cant assign to array.. Thanks for any help..
If arraytype = "staffcost" Then
Dim myarray(32, 13)
checknum = 1
For z = 93 To 129
ck = Cells(z, 1)
If ck <> " Bonus" And ck <> " Salary" And ck <> " Pension Fund" And ck <> " Benefits" And ck <> " Contract Cost" Then
For x = 1 To 13
myarray(checknum, x) = Cells(z, x)
Next x
checknum = checknum + 1
End If
Next z
ElseIf arraytype = "general" Then
myarray = Range("A191:M222")
End If
If arraytype = "staffcost" Then
Dim myarray(32, 13)
checknum = 1
For z = 93 To 129
ck = Cells(z, 1)
If ck <> " Bonus" And ck <> " Salary" And ck <> " Pension Fund" And ck <> " Benefits" And ck <> " Contract Cost" Then
For x = 1 To 13
myarray(checknum, x) = Cells(z, x)
Next x
checknum = checknum + 1
End If
Next z
ElseIf arraytype = "general" Then
myarray = Range("A191:M222")
End If