Displaying row values ​​in a column

In Excel, trying to show the value of cell A1 in the values ​​of cell C1 and B1 in C2 and vice versa. not sure how to do this. Is there a way to do this in VBA? Please help!

Example

+3


source to share


3 answers


try the following code



Public Sub program()
    Dim i As Long
    Dim j As Long

    i = 1
    j = 1
    Do While Cells(i, "A").Value <> ""
        Cells(j, "C").Value = Cells(i, "A").Value
        j = j + 1
        Cells(j, "C").Value = Cells(i, "B").Value
        i = i + 1
        j = j + 1
    Loop
End Sub

      

+2


source


Do this by using the formula: =IF(MOD(ROW();2)=1;INDEX(A:B;(1+ROW())/2;1);INDEX(A:B;ROW()/2;2))

. Just place it on C1

and drag it.



0


source


Copy & Paste - Paste into Cell C1, Mark Transpose Box

Shortcut: Ctrl + C (together) Then Alt, E, S, E (in a row)

-2


source







All Articles