Have you tried to dim z1 as a variant instead of a double in the same code?