You can use an array formula like

=STDEV(IF(B2:B100="Y",A2:A100))

confirmed with CTRL+SHIFT+ENTER