rearranging column data

MR3

Board Regular
Joined
Jun 10, 2008
Messages
175
i have data in columns 1 through 6 and i would like to rearrange them in my macro via an array 2 3 5 1 4 6.

the array of rearrangement would be located in column A of Sheet1

2
3
5
1
4
6

and the column data to be rearranged would be in Sheet2
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try

Code:
Sub Xpse()
Dim LR As Long, i As Long
With Sheets("Sheet2")
    LR = .Range("A" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(6).Value = Application.Transpose(.Range("A" & i).Resize(, 6))
    Next i
End With
End Sub
 
Upvote 0
Give this a try...
Code:
Sub RearrageRows()
  Dim vArr As Variant, LastRow As Long
  LastRow = Worksheets("Sheet2").Columns("A:F").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
  vArr = Application.Index(Worksheets("Sheet2").Cells, Evaluate("Row(1:" & LastRow & ")"), WorksheetFunction.Transpose(Worksheets("Sheet1").Range("A1:A6")))
  Worksheets("Sheet2").Columns("A:F").Clear
  Worksheets("Sheet2").Range("A1").Resize(LastRow, 6) = vArr
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

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