Rearrange the data in excel

Apple Ang

New Member
Joined
Aug 28, 2006
Messages
11
Hi,

This might easy, but I really need help from you all. I'm a beginner, & I hope I can learn VBA through this board. I problem as below.

I've a data which originally shown as below:
Book4
ABCDEFGHIJKLMN
1CustomerCustomerIndexPartNumberVendorStatusProposedPartNumberProposedVendorStatusProposedPartNumberProposedVendorStatusProposedPartNumberProposedVendorStatus
2ABCABC-0001223-00013MOriM00095MAltA101-2221MOLAlt747-B01ITTAlt
3IDAIDA-010C0603ZGAVXOriGRM188JRMuraAlt2238-5654YagAlt
Sheet1


I would like to hv a macro which will help me to rearrange the data to below format. The data for column start from F will be copy to another row but the data in column A & B will remain the same with that particular row. I can do it manually but I might kill me if I've more than 100 rows.
Book4
ABCDE
13CustomerCustomerIndexPartNumberVendorStatus
14ABCABC-0001223-00013MOri
15ABCABC-0001M00095MAlt
16ABCABC-0001A101-2221MOLAlt
17ABCABC-0001747-B01ITTAlt
18IDAIDA-010C0603ZGAVXOri
19IDAIDA-010GRM188JRMuraAlt
20IDAIDA-0102238-5654YagAlt
Sheet1


Can somebody help me on this? Your help much appreciated.

Thanks & warm regards,
Apple
 

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.
Hi Apple,

How about this:

Code:
Sub Rearrange()

For i = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1 'start at the bottom row upwards 1 at a time until row 2
    For j = Range("IV" & i).End(xlToLeft).Column To 8 Step -3 'then at the furthest right col moving left 3 at a time until col 8
        Rows(i + 1).Insert 'insert a row immediately below current one
        Range(Cells(i, "A"), Cells(i, "B")).Copy Cells(i + 1, "A") 'copy current Cust & Index to col A:B in row below
        Range(Cells(i, j - 2), Cells(i, j)).Cut Cells(i + 1, "C") 'copy current PartNo, Vendor & Status to col C:E in row below
    Next j 'move left to the next set until you hit column 8
Next i 'move up to the next row until you hit row 2

Range("F1:N1").Clear 'delete excess titles

End Sub

All the best
PeregrinTook
 
Upvote 0
Hi PeregrinTook,

Thanks a lot for your great help. This is what I'm looking for. Really help me a lot.

Agains, thanks.

Warmest regards,
Apple
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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