Hi,
Please follow below Steps.
1) Find out UDF that used your deleted query.
2) Then gets focus on that UDF and click on Alt+Shift+F2.
3) It will show you User Define Value Setup Window.
4) Checks that your query is used or not if used then select "Without Search in User-Define Values"
5) Click on update button.
6) Then try to delete that query.
Regards,
Nishit Makadia