I think that your WriteTxt() macro should go in a standard module, not in the worksheet area.