How to move rows into columns

alive15

New Member
Joined
Jul 13, 2016
Messages
36
Good afternoon all, hope all is well today. I have one column with ten-thousand rows of data. I need to extract all the even numbered rows and move it into column B. Furthermore, both columns need to shrink to 50 rows. How can I accomplish this faster without manually cutting and pasting?

Notes: All odd numbered rows begin with "C", all even numbered rows begin with any number between "0-9".

Thanks! Have a great day.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Sorry, not 50, the correct # of rows per column is 5,000 rows.

I want to shrink the first column (originally 10,000 rows) into two columns of 5,000 rows each.
 
Upvote 0
Try this, The results in columns B and C

VBA Code:
Sub move_rows()
  Dim a(), b(), i As Long, j As Long
  a = Range("A1:A10000").Value
  ReDim b(1 To 5000, 1 To 2)
  j = 1
  For i = 1 To 10000 Step 2
    b(j, 1) = a(i, 1)
    b(j, 2) = a(i + 1, 1)
    j = j + 1
  Next
  Range("B1").Resize(5000, 2).Value = b
End Sub
 
Upvote 0
with Power Query

DataColumn1Column2
C1C12
2C34
4C56
C3
C5
6


Code:
// Table2
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    IF = Table.AddColumn(Table.TransformColumnTypes(Source,{{"Data", type text}}), "Custom", each if Text.Contains([Data], "C") then true else false),
    List = Table.AddColumn(Table.Group(IF, {"Custom"}, {{"Count", each _, type table}}), "Custom.1", each Table.Column([Count],"Data")),
    Extract = Table.TransformColumns(List, {"Custom.1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    Split = Table.SplitColumn(Table.SelectColumns(Extract,{"Custom.1"}), "Custom.1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1.1", "Custom.1.2", "Custom.1.3"}),
    Top5000 = Table.FirstN(Table.Transpose(Split),5000)
in
    Top5000
 
Last edited by a moderator:
Upvote 0
Dante, I tried your code. It did move the correct data to the B column. But column A still looks the same, it did not delete the even numbered rows and did not shrink column A to 5000
 
Upvote 0
I appreciate the links Sandy, but I am not a big excel user at my office, so for me, it is not worth spending an hour or so studying up on it. I'm grateful for the help you guys are giving me, but I am just looking for something simple to get my work done (obviously writing code is not simple, but copying and pasting code is very simple).

Are you familiar with Dante's code by any chance? If you are able to help me with that code, that would be excellent for me. I am just looking to get my work organized and then move on to the next task. Thanks again, I don't mean to offend you or devalue your efforts.
 
Upvote 0

Forum statistics

Threads
1,215,262
Messages
6,123,938
Members
449,134
Latest member
NickWBA

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