VBA several columns into 1 column

neveu

Board Regular
Joined
Jan 27, 2009
Messages
225
hello Forum,

could you please advise how to adress the next issue?
i have several columns with data ( up to 50) starting with column M.
each column has a different number of rows. ( from 10 up to 30)

i would need your help to consolidate all this columns into a single column: let's say column K.

thank you in advance
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If your data starts from Column K then in which column do you want your data to be consolidated.
 
Upvote 0
Ok, now let me know something more that has your data header and from which row your data starts? After consoldating the data you want to delete those columns ? (From col m to onword)
 
Upvote 0
the data starts from row 1 and yes i would need to delete the columns after being consolidated
 
Upvote 0
Try this

Code:
Sub MoveAllDataToColumnK()
    Dim i As Long, ws As Worksheet, rngCopy As Range, rngEnd As Range
    Set ws = ActiveSheet
    Do Until ws.Cells(1, 13).Value = ""
        Set rngCopy = ws.Range("M1", ws.Cells(ws.Rows.Count, "M").End(xlUp))
        Set rngEnd = ws.Cells(ws.Rows.Count, "K").End(xlUp).Offset
        rngEnd.Resize(rngCopy.Rows.Count, 1).Value = rngCopy.Value
        rngCopy.EntireColumn.Delete
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,114
Messages
6,170,187
Members
452,309
Latest member
liclice

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top