Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying rows values in column

Tags:

excel

vba

In Excel, Am trying to show A1 cell value in C1 and B1 cell value in C2 and vice versa. not sure how to do this. Is there any way to do this in VBA? Please Help!

Sample

like image 410
Narendiran GP Avatar asked Jun 11 '26 10:06

Narendiran GP


1 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
like image 183
Zsmaster Avatar answered Jun 13 '26 15:06

Zsmaster