rearranging columns by reversing in location and create headers

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hi guys,
I have untidy data in columns I:N .I would arranging again in columns A:E
column A=column N
column B=column L
column C=column K
column D=column J
column E=column I
and every number is merged in column N,K,J,I then should cancel merging as show in column A,C,D,E and at the same time should merge the cells are consecutive in column L as show in column B for the number is merged in column N
after that should delete all of columns from I:N
and should create headers in row1.


before
COL.xlsm
IJKLMN
1
22,700.00JAPANBRIDGESTONEBS 1200R20 18PR G580 1
3JAP
42,680.00JAPANBRIDGESTONEBS 1200R20 18PR R187 2
5JAP
62,550.00JAPANBRIDGESTONEBS 1200R24 G5803
72,600.00JAPANBRIDGESTONEBS 1200R24 G582 JAP4
84,160.00JAPANBRIDGESTONEBS 1400R20 TCF R180 5
9JAP
104,280.00JAPANBRIDGESTONEBS 1400R20VSJ TCF JAP6
11420THILANDBRIDGESTONEBS 175/65R14 EP1507
12180TURKEYBRIDGESTONEBS 175/70R13 EP150 82S 8
13TURK
14280THILANDBRIDGESTONEBS 175/70R13 EP150 THI9
15215THILANDBRIDGESTONEBS 175/70R14 MY02 THI10
16260IndonesiaBRIDGESTONEBS 185/65R14 EP150 11
17IND
18315JAPANBRIDGESTONEBS 185/65R15 B250 JAP12
19290IndonesiaBRIDGESTONEBS 185/70R13 EP150 13
20IND
21360THILANDBRIDGESTONEBS 185/70R14 B250 THI14
22435TURKEYBRIDGESTONEBS 185R14C R660 15
23102R100R 8 TURK
24288THILANDBRIDGESTONEBS 195/60R15 EP150 THI16
25267JAPANBRIDGESTONEBS 195/60R15 T001 JAP17
26335JAPANBRIDGESTONEBS 195/65R15 EP150 JAP18
27740JAPANBRIDGESTONEBS 195/70R15C R623 19
28JAP
29490THILANDBRIDGESTONEBS 195R14C R623 THI20
30488TURKEYBRIDGESTONEBS 195R14C R660 TURK21
31428JAPANBRIDGESTONEBS 195R15C 613V JAP22
32490THILANDBRIDGESTONEBS 195R15C R623 THI23
33490TURKEYBRIDGESTONEBS 195R15C R660 TURK24
34409TURKEYBRIDGESTONEBS 205/65R15 EP150 25
35TURK
36300THILANDBRIDGESTONEBS 205/65R15 T005 THI26
SS



result should be

COL.xlsm
ABCDEFGHIJKLMN
1ITEMBRANDMARKSORIGINPRICE
21BS 1200R20 18PR G580 JAPBRIDGESTONEJAPAN2,700.00
32BS 1200R20 18PR R187 JAPBRIDGESTONEJAPAN2,680.00
43BS 1200R24 G580BRIDGESTONEJAPAN2,550.00
54BS 1200R24 G582 JAPBRIDGESTONEJAPAN2,600.00
65BS 1400R20 TCF R180 JAPBRIDGESTONEJAPAN4,160.00
76BS 1400R20VSJ TCF JAPBRIDGESTONEJAPAN4,280.00
87BS 175/65R14 EP150BRIDGESTONETHILAND420.00
98BS 175/70R13 EP150 82S TURKBRIDGESTONETURKEY180.00
109BS 175/70R13 EP150 THIBRIDGESTONETHILAND280.00
1110BS 175/70R14 MY02 THIBRIDGESTONETHILAND215.00
1211BS 185/65R14 EP150 INDBRIDGESTONEIndonesia260.00
1312BS 185/65R15 B250 JAPBRIDGESTONEJAPAN315.00
1413BS 185/70R13 EP150 INDBRIDGESTONEIndonesia290.00
1514BS 185/70R14 B250 THIBRIDGESTONETHILAND360.00
1615BS 185R14C R660 102R100R 8 TURKBRIDGESTONETURKEY435.00
1716BS 195/60R15 EP150 THIBRIDGESTONETHILAND288.00
1817BS 195/60R15 T001 JAPBRIDGESTONEJAPAN267.00
1918BS 195/65R15 EP150 JAPBRIDGESTONEJAPAN335.00
2019BS 195/70R15C R623 JAPBRIDGESTONEJAPAN740.00
2120BS 195R14C R623 THIBRIDGESTONETHILAND490.00
2221BS 195R14C R660 TURKBRIDGESTONETURKEY488.00
2322BS 195R15C 613V JAPBRIDGESTONEJAPAN428.00
2423BS 195R15C R623 THIBRIDGESTONETHILAND490.00
2524BS 195R15C R660 TURKBRIDGESTONETURKEY490.00
2625BS 205/65R15 EP150 TURKBRIDGESTONETURKEY409.00
2726BS 205/65R15 T005 THIBRIDGESTONETHILAND300.00
SS
 
that's mystery to be fast
Don't keep it a mystery, just ask questions.
The slowest part for most code is how many times you access the spreadsheet which is mostly when you read and write to it.
Reading a lot of data at once and writing a lot of data once is much faster than doing multiple read and writes. So you do one bulk read and one bulk write.

The rest of the processing is done in memory using the array.
This generally only works well if you don't have to keep formulas that need to be written back in the output.

In my code:
Rich (BB code):
        Set rngSrc = .Range("I2", .Cells(rowLastSrc, "N"))
        arrSrc = rngSrc.Value                                  ' This reads all the data in one go into an array

    ' the rest of the code is in between these 2
    With rngDest.Offset(1).Resize(iDest, UBound(arrDest, 2))
        .Value = arrDest                                           ' This writes all the data in one go back to the spreadsheet from the 2nd array
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,217
Messages
6,123,673
Members
449,116
Latest member
HypnoFant

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