# How to fill empty cells with the next not empty cell from the same row?

Copper Contributor

# How to fill empty cells with the next not empty cell from the same row?

Welcome.

I have been looking for two hours, but I can't find the answer:

How do I fill empty cells in excel with the next value in the row?

Well, I have the column year 1990. Sometimes there is a number and sometimes there is no. And I need to fill in the cell in the column called 1990 year with the next closest number from the same row. This may be in the 3rd or maybe in the 7th column, because the next number may be in the 1995 year or 1998 year or another. How to write a formula to find it.

I tried this formula:
= INDEX(C4:AG4,MATCH(TRUE,INDEX((C4:AG4<>0),0),0))

=IF(A2="",INDEX(A2:AG2,MATCH(TRUE,INDEX((A2:AG2<>"")+(A2:AG2<>0),0),0)),A2)
but it does not work.

I greet and thank you in advance for your help.

This is the file: gdp_per_capita_ppp_constant_2017_modified

Second question: Why this formula is wrong for above excel?

=IF(B2="",C1,B2)

Greetings

1 Reply

# Re: How to fill empty cells with the next not empty cell from the same row?

Second question: Why this formula is wrong for above excel?

=IF(B2="",C1,B2)
similar to formular in c24?
=IF(C24="",D24,G24)
i guess you refer to c24 self in the formular.

if so,u had put =IF(B2="",C1,B2) in cell B2 I guess.
try put this formula to b1 rather than B2.