User ( posted:

At the begining of the function did you declare the variable as an integer

Dim iCSVInputFileNumber As integer.

Also when being used the # sign is not always used together with the var


iCSVInputFileNumber assigns the next available file number
but when you open and close the file you have to have the # infront