Moving data from rows to column A

ExcelSwede

New Member
Joined
Mar 9, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi everyone

This is an easy case. For all except novices like me.

Transform an adress list like this:
1622024178958.png


To show up in column A like this
1622024296946.png


I hope someone can build a sub that can do the transformation in a loop until last row.

The purpose is to print adresses from Excel to a sheet of adress-stickers. When data i correct siuted in column A, I think that I can handle the rest.

Thanks for your kindness

ExcelSwede
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You want all the data put in Column A but you do not show where the original data is.
 
Upvote 0
How about
VBA Code:
Sub ExcelSwede()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
   
   With Sheets("Sheet1")
      Ary = .Range("A2:C" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 1)
   
   For r = 1 To UBound(Ary)
      For c = 1 To UBound(Ary, 2)
         nr = nr + 1
         Nary(nr, 1) = Ary(r, c)
      Next c
   Next r
   Sheets("Sheet2").Range("A1").Resize(nr, 1).Value = Nary
End Sub
Change sheet names & ranges to suit.
 
Upvote 0
How about
VBA Code:
Sub ExcelSwede()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
  
   With Sheets("Sheet1")
      Ary = .Range("A2:C" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 1)
  
   For r = 1 To UBound(Ary)
      For c = 1 To UBound(Ary, 2)
         nr = nr + 1
         Nary(nr, 1) = Ary(r, c)
      Next c
   Next r
   Sheets("Sheet2").Range("A1").Resize(nr, 1).Value = Nary
End Sub
Change sheet names & ranges to suit.
Thanks Fluff, works perfect.

I tried myself with some clue from exampels in "similar threads" and ended upp with this:

For i = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
Range("A" & i & ":" & "A" & i + 1).Offset(1).EntireRow.Insert
Range("B" & i).Cut Range("A" & i).Offset(1)
Range("C" & i).Cut Range("A" & i).Offset(2)
Next


That sub do the job, even if it take some time while the sheet kan contain 2000 rows. Your sub is much faster and save the original data. My own sub transform original data into a new layout.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,636
Members
449,043
Latest member
farhansadik

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