When i copy formulas (by dragging one cell across many rows) for segmented data (seperated by empty cells), is it possible to copy ONLY when the leading cell is non-empty?

For example:

1 A
2
3

4
5
6

7
8
9

If A is a formula and I want to drag it down until row with leading cell 9. What should i do if i don't want it to display anything for the empty rows between 3&4, and 6&7?