Search code examples
google-sheetsspreadsheetgoogle-apps

Google sheets: swap column value if present


How can I write a formula in Google sheets to swap a value between Column 1 and Column 2 only if there's a value in Column 2?

    1    |    2
-------------------
    V    |
    S    |    T    

I want the second row to swap, not the first. Any help?


Solution

  • Turns out it's pretty easy. Here's the formula for the first column:

    =if(B2, B2, A2)