Here's what my excel table looks like:

[example table](https://i.stack.imgur.com/kXe4r.png)

I want to populate a column called primary code, where it lists the primary code associated with that value. Essentially, I would like primary code to be 10 for Facility ID=1 and Facility Name=X Site and 15 where Facility ID=1 and Facility Name=Z Site. However, I can't figure out a simple IF function to use because of those blank spaces in the data. The blank spaces essentially mean that the row takes on the value of the previous row. It's not feasible for me to try to fill in those blank cells because my actual data has more than 500,000 observations.

Basically, I need to figure out a code that assigns each facility of the same name the same primary code, which should be the first code listed in that section of facility names. If anyone has any insights, that would really help!