ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move data from different columns into one column, but different rows. (https://www.excelbanter.com/excel-programming/292801-move-data-different-columns-into-one-column-but-different-rows.html)

willik[_2_]

Move data from different columns into one column, but different rows.
 
Hello,
I am new to Excel and VB. I am trying to write a macro in VB to do th
following as shown in example.

Example:

I need to move (cut & paste ) the data from columns B through F int
column A. The data in Cell B1 would need to go into cell A11, data i
Cell B2 into cell A12 . . . B6 into cell A16, and then move data i
cell C1 into A17, C2 into cell A18 . . . and so on for the rest of th
columns. Shown below see existing positions of data and fina
position.

****NOTE***** The number of rows and number of columns changes on dail
basis with the data I am exporting from another database. So ther
might be columns out to " T " with different number of rows in eac
column.

Existing positions of data:

col col col col col
col
A B C D E
F

A1 B1 C1 D1 E1 F1
A2 B2 C2 D2 E2 F2
A3 B3 C3 D3 E3 F3
A4 B4 C4 D4 E4 F4
A5 B5 C5 D5 F5
A6 B6 C6 D6 F6
A7 C7 D7 F7
A8 C8 D8 F8
A9 D9 F9
A10 F10


Final positions of data after moved:

col
A

A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
B1
B2
B3
B4
B5
B6
C1
C2
C3
C4
C5
C6
C7
C8
D1
D2
D3
D4
D5
D6
D7
D8
D9
E1
E2
E4
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10

P.S. I had a similar task answered on another thread. The thread was
Move Different Columns of Data to Single Column. "

Thank you for any help.
Regards

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Move data from different columns into one column, but different rows.
 
Sub PutinColumnA()
Dim rng As Range
Dim rw As Long
Dim col As Range, cell1 As Range
Set rng = Range("B1").CurrentRegion
If rng.Columns(1).Column = 1 Then _
Set rng = rng.Offset(0, 1).Resize(, rng.Columns.Count - 1)
rw = 1
For Each col In rng.Columns
For Each cell1 In col.Cells
If Not IsEmpty(cell1) Then
Cells(rw, 1).Value = cell1.Value
rw = rw + 1
cell1.ClearContents
End If
Next
Next
End Sub
--
Regards,
Tom Ogilvy


"willik " wrote in message
...
Hello,
I am new to Excel and VB. I am trying to write a macro in VB to do the
following as shown in example.

Example:

I need to move (cut & paste ) the data from columns B through F into
column A. The data in Cell B1 would need to go into cell A11, data in
Cell B2 into cell A12 . . . B6 into cell A16, and then move data in
cell C1 into A17, C2 into cell A18 . . . and so on for the rest of the
columns. Shown below see existing positions of data and final
position.

****NOTE***** The number of rows and number of columns changes on daily
basis with the data I am exporting from another database. So there
might be columns out to " T " with different number of rows in each
column.

Existing positions of data:

col col col col col
col
A B C D E
F

A1 B1 C1 D1 E1 F1
A2 B2 C2 D2 E2 F2
A3 B3 C3 D3 E3 F3
A4 B4 C4 D4 E4 F4
A5 B5 C5 D5 F5
A6 B6 C6 D6 F6
A7 C7 D7 F7
A8 C8 D8 F8
A9 D9 F9
A10 F10


Final positions of data after moved:

col
A

A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
B1
B2
B3
B4
B5
B6
C1
C2
C3
C4
C5
C6
C7
C8
D1
D2
D3
D4
D5
D6
D7
D8
D9
E1
E2
E4
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10

P.S. I had a similar task answered on another thread. The thread was "
Move Different Columns of Data to Single Column. "

Thank you for any help.
Regards,


---
Message posted from http://www.ExcelForum.com/




willik[_4_]

Move data from different columns into one column, but different rows.
 
Tom,
Thank you. This worked perfectly.

Regards, (willik

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 12:06 PM.

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