Forum Discussion
Function crashes: Operation is not valid due to the current state of the object.
Hi smikou ,
that error message often is a sign of a corrupted file.
So what you did to start from scratch was the solution.
Hi ImkeF
It seems that I forgot to make one of the arguments of the function variable, that's why it seemed like working... but it's not 😞
I would like to send a sample file like explained on edhans link, but the problem concerns excel files importation.
My function is simple, it merges a few excel files into one, and each time it gets data from 2 different sheets.
The arguments on this function are: the file's name, it's path and the Sheet's name.
#"File" = #"Lignes filtrées1"{[Name=FileName,#"Folder Path"=Path]}[Content],
#"Excel importé" = Excel.Workbook(#"File"),
Sheet = #"Excel importé"{[Item=Sheet,Kind="Sheet"]}[Data],
The problem comes from the last parameter: Sheet.
When I replace the parameter Sheet by the real name of one of the sheets (e.g. "Sheet1" or "Sheet2"), it works just fine.
But when I tell the function to get Sheet from a column (with only "Sheet1" or "Sheet2" as values) like FileName and Path, it crashes.