Can anyone help..........

I'm trying to right some script which uses the COUNTIF function which uses variable instead of fixed cell references. Does anyone know how to do this.

Normal formula is =COUNTIF(A1:A10),B1) but I want to replace the B1 part with a variable which changes.

Someone please help before I throw my computer out of the window.......