I need a formula that looks in a column of data for a "1" and when it finds it, starts numbering from 1 to a specified number in a different column (and stops numbering at the max limit).

So, in column A1 - A10, cell A3 content is 1 (all other cells in that column are empty). My range is 1 - 5.

The formula in column B1 - B10 would look for a 1 in column A1 - A10 and start numbering from 1 - 5 when it finds it. Like so:

A1 = "" B1 = ""
A2 = "" B2 = ""
A3 = 1 B3 = 1
A4 = "" B4 = 2
A5 = "" B5 = 3
A6 = "" B6 = 4
A7 = "" B7 = 5
A8 = "" B8 = ""
A9 = "" B9 = ""
A10 = "" B10 = ""