Machine and method for the automatic preparation of medication, comprising: - a starting products area comprising at least one receptacle with base products - a transfer tools area further comprising at least one transfer tool - a prepared products area comprising at least one container and - one robot with holding means for transporting the receptacle, the transfer tool and/or the container wherein the robot, the starting products area, the transfer tools area, and the prepared products area are disposed in the same cabinet or chamber of the machine, so that the robot is adapted to transport the receptacle, the transfer tool and/or the container between the areas in the chamber. The machine further comprising a holding device between the receptacle, the transfer tool or the container and the robots holding means, said holding device comprising elastic means for fixation to different sizes/forms of receptacles, transfer tools or containers.