ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to copy data from different columns in an Excel to one column (https://www.excelbanter.com/excel-programming/407861-how-copy-data-different-columns-excel-one-column.html)

Priya Gautam[_2_]

How to copy data from different columns in an Excel to one column
 
How to copy data from different columns in an Excel to one column at once.
For example if i have data spread from column A to Z spread over 100 rows.
How do i bring all the values to column A.

filo666

How to copy data from different columns in an Excel to one column
 
please select your range and run this code:

Sub concolumn()
Dim arr1() As Variant
Dim cnt1, cnt2, a, aa, aaa, b, bb, bbb As Integer
cnt1 = 1
aa = Selection.Rows.Count
bb = Selection.Columns.Count
aaa = Selection.Row - 1
bbb = Selection.Column - 1
For b = 1 To bb
For a = 1 To aa
Cells(a + aaa, b + bbb).Select
If Cells(a + aaa, b + bbb) < Empty Then
ReDim Preserve arr1(cnt1)
arr1(cnt1) = Cells(a + aaa, b + bbb)
cnt1 = cnt1 + 1
End If
Next
Next
For cnt2 = 1 To UBound(arr1)
Cells(cnt2, 1) = arr1(cnt2)
Next
End Sub

"Priya Gautam" wrote:

How to copy data from different columns in an Excel to one column at once.
For example if i have data spread from column A to Z spread over 100 rows.
How do i bring all the values to column A.



All times are GMT +1. The time now is 01:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com