Turn multiple columns into one

Asked

Viewed 443 times

2

Hello, I do not program VBA and I am not able to make a code that did the following:

|A |B |C |
----------
|1 |6 |11|
|2 |7 |12|
|3 |8 |13|
|4 |9 |14|
|5 |10|15|

My table has several columns like these up there, I would like you to help me with a routine that I would read from column B and always put under column A, in this case it would be in sequence from 1 to 15 in column A, this is possible?

Upshot:

|A  |
-
|1  |
|2  |
|3  |
|4  |
|5  |
|6  |
|7  |
|...|
|14 |
|15 |
  • When Voce says table means an excel spreadsheet, vectors (arrays) or is an access database table?

  • An excel table, I would like to do a macro for it...

1 answer

1

Reply from the author in comment.

Sub macro()
    'Step 1:  Declare your variables.
        Dim MyRange As Range
        Dim MyCell As Range
        Dim i As Double
        i = 6000
    'Step 2:  Define the target Range.
        Set MyRange = Range("A1:T5917")
    'Step 3:  Start looping through the range.
        For Each MyCell In MyRange
    'Step 4:  Do something with each cell.
        MyCell.Cut
        Cells(i, 1).Select
        ActiveSheet.Paste
    'Step 5: Get the next cell in the range
        i = i + 1
        Next MyCell
End Sub

I put in the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.