sort whole ranges based on selection multiple cells at once without any criteria

abdo meghari

Well-known Member
Joined
Aug 3, 2021
Messages
612
Office Version
  1. 2019
Hi experts ,
I no know if this way could be sort it !

I want to sort the data based on my choices, where the data will be arranged based on who will be selected first for cells in column A , then the next based on the selection of a cell or several cells at the same time. In this case, it will be arranged in an orderly manner and if I select new data are not selected before then will copy directly to below data have already selected and sorted . And in the case of choosing the same elements that were previously organized, then they are organized again and make the ones below them rise to the top

original data
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1220BS 1200 R20 18PR G580 THI20
32CCR-1221BS 1200 R20 18PR G580 JAP30471
43CCR-1222BS 1200R20-18PR R187 JAP9
54CCR-1223BS 1200R24 G580508
65CCR-1224BS 1200R24 G5822
76CCR-1225BS 13 R22.5 R187 JAP4
87CCR-1226BS 1400R20 TCF R180 JAP2
98CCR-1227BS 1400R20 TCF R180BZ JAP4
109CCR-1211BS 1400R20VSJ TCF JAP2255
1110CCR-1212BS 165 R13C R624 IND44
1211CCR-1213BS 175/70R13 EP150 THI2
1312CCR-1214BS 185/65R15 B250 JAP2
1413CCR-1215BS 185/65R15 T001 JAP1
1514CCR-1216BS 195/75R16C R613 JAP6
1615CCR-1217BS 195R14C 613 JAP4
1716CCR-1218BS 195R14C R623 THI4
1817CCR-1219BS 195R15C 613V JAP44
1918CCR-1228BS 205/60R16 T005 THI8
2019CCR-1229BS 205/70R15C R623 THI8405
2120CCR-1230BS 205R16C D840 THI26
2221CCR-1231BS 215/50 R17 EP300 THI10
2322CCR-1232BS 215/55R17 T005 JAP4
2423CCR-1233BS 215/60R16 ER30 JAP88
2524CCR-1234BS 215/65R15 T005A IND44
2625CCR-1235BS 215/70R15C R624 HD109S107S 8 TURK6
2726CCR-1236BS 225/40R18PR 005A JAP8
2827CCR-1237BS 225/55R17 EP300 THI1
2928CCR-1238BS 225/55R17 T005A JAP8
3029CCR-1239BS 225/55R18 AL001 JAP4
3130CCR-1240BS 225/60R17 D-SPORT JAP15
3231CCR-1241BS 225/60R18 ALENZA001 JAP4
3332CCR-1242BS 225/70R15C R623 JAP8
3433CCR-1243BS 235/35ZR19 RE050A JAP4
3534CCR-1244BS 235/50R18 AL01 JAP8
3635CCR-1245BS 235/55R17 ER300 JAP8
3736CCR-1246BS 235/65R16C R660 TURK12
3837CCR-1247BS 245/40R18PR 050A JAP8
3938CCR-1248BS 245/40R19 T005 JAP4
4039CCR-1249BS 245/40ZR20 PSPORT JAP4
4140CCR-1250BS 245/45R17 T05A JAP4
4241CCR-1251BS 245/45R18 EP300 THI4
4342CCR-1252BS 245/45R19 T005A JAP4
4443CCR-1253BS 245/70R17 684A JAP2
4544CCR-1254BS 255/35R19 S001 JAP4
4645CCR-1255BS 255/50R20 AL001 JAP8
4746CCR-1256BS 255/70R15C D840 THI33
4847CCR-1257BS 265/55R20 D693 LCRUSER JAP4
4948CCR-1158BS 265/60R18 D840 JAP4
5049CCR-1159BS 265/65R17 D840 JAP4
5150CCR-1160BS 265/65R18 D693 JAP4
5251CCR-1161BS 265/70R16 D840 THI76
5352CCR-1162BS 275/35R21 RE21 JAP4
5453CCR-1163BS 275/65R18 AL01 JAP12
5554CCR-1164BS 285/60R18 DHPS JAP8
5655CCR-1165BS 285/65R17 R683 JAP8
5756CCR-1166BS 295/35R20 S001 JAP4
5857CCR-1167BS 315/80R22.5-18PR G580 JAP12
5958CCR-1168BS 315/80R22.5-18PR G582 THI12
6059CCR-1169BS 325/95 R24 M840 JAP62
6160CCR-1170BS 385/65 R22.5 R164 JAP4
6261CCR-1171BS 445/65R22.5 R164 JAP24
6362CCR-1172BS 650R16 R230 JAP8
6463CCR-1173BS 385/65 R22.5 R164 JAP16
6564CCR-1174BS 445/65R22.5 R164 JAP18
6665CCR-1175BS 650R16 R230 JAP20
REPORT

examples:
pic: select cells A15,A19,A23
1.PNG
View attachment 87306
to become like this
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1216BS 195/75R16C R613 JAP6
32CCR-1228BS 205/60R16 T005 THI8
43CCR-1232BS 215/55R17 T005 JAP4
54CCR-1220BS 1200 R20 18PR G580 THI20
65CCR-1221BS 1200 R20 18PR G580 JAP30471
76CCR-1222BS 1200R20-18PR R187 JAP9
87CCR-1223BS 1200R24 G580508
98CCR-1224BS 1200R24 G5822
109CCR-1225BS 13 R22.5 R187 JAP4
1110CCR-1226BS 1400R20 TCF R180 JAP2
1211CCR-1227BS 1400R20 TCF R180BZ JAP4
1312CCR-1211BS 1400R20VSJ TCF JAP2255
1413CCR-1212BS 165 R13C R624 IND44
1514CCR-1213BS 175/70R13 EP150 THI2
1615CCR-1214BS 185/65R15 B250 JAP2
1716CCR-1215BS 185/65R15 T001 JAP1
1817CCR-1217BS 195R14C 613 JAP4
1918CCR-1218BS 195R14C R623 THI4
2019CCR-1219BS 195R15C 613V JAP44
2120CCR-1229BS 205/70R15C R623 THI8405
2221CCR-1230BS 205R16C D840 THI26
2322CCR-1231BS 215/50 R17 EP300 THI10
2423CCR-1233BS 215/60R16 ER30 JAP88
2524CCR-1234BS 215/65R15 T005A IND44
EXAMPLE1



pic2 to select A5,A13,A21
2.PNG
View attachment 87307
to become to data have already sorted bottom
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1216BS 195/75R16C R613 JAP6
32CCR-1228BS 205/60R16 T005 THI8
43CCR-1232BS 215/55R17 T005 JAP4
54CCR-1223BS 1200R24 G580508
65CCR-1214BS 185/65R15 B250 JAP2
76CCR-1230BS 205R16C D840 THI26
87CCR-1220BS 1200 R20 18PR G580 THI20
98CCR-1221BS 1200 R20 18PR G580 JAP30471
109CCR-1222BS 1200R20-18PR R187 JAP9
1110CCR-1224BS 1200R24 G5822
1211CCR-1225BS 13 R22.5 R187 JAP4
1312CCR-1226BS 1400R20 TCF R180 JAP2
1413CCR-1227BS 1400R20 TCF R180BZ JAP4
1514CCR-1211BS 1400R20VSJ TCF JAP2255
1615CCR-1212BS 165 R13C R624 IND44
1716CCR-1213BS 175/70R13 EP150 THI2
1817CCR-1215BS 185/65R15 T001 JAP1
1918CCR-1217BS 195R14C 613 JAP4
2019CCR-1218BS 195R14C R623 THI4
2120CCR-1219BS 195R15C 613V JAP44
2221CCR-1229BS 205/70R15C R623 THI8405
2322CCR-1231BS 215/50 R17 EP300 THI10
2423CCR-1233BS 215/60R16 ER30 JAP88
EXAMPLE2


pic3:
select cells A3,A25,A19,A13 to become like this
3.PNG
View attachment 87308
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1216BS 195/75R16C R613 JAP6
32CCR-1232BS 215/55R17 T005 JAP4
43CCR-1223BS 1200R24 G580508
54CCR-1221BS 1200 R20 18PR G580 JAP30471
65CCR-1234BS 215/65R15 T005A IND44
76CCR-1228BS 205/60R16 T005 THI8
87CCR-1214BS 185/65R15 B250 JAP2
98CCR-1230BS 205R16C D840 THI26
109CCR-1220BS 1200 R20 18PR G580 THI20
1110CCR-1222BS 1200R20-18PR R187 JAP9
1211CCR-1224BS 1200R24 G5822
1312CCR-1225BS 13 R22.5 R187 JAP4
1413CCR-1226BS 1400R20 TCF R180 JAP2
1514CCR-1227BS 1400R20 TCF R180BZ JAP4
1615CCR-1211BS 1400R20VSJ TCF JAP2255
1716CCR-1212BS 165 R13C R624 IND44
1817CCR-1213BS 175/70R13 EP150 THI2
1918CCR-1215BS 185/65R15 T001 JAP1
2019CCR-1217BS 195R14C 613 JAP4
2120CCR-1218BS 195R14C R623 THI4
2221CCR-1219BS 195R15C 613V JAP44
2322CCR-1229BS 205/70R15C R623 THI8405
2423CCR-1231BS 215/50 R17 EP300 THI10
2524CCR-1233BS 215/60R16 ER30 JAP88
EXAMPLE3



so how sort these data again:
1-should arrange based on selected multiple cells in column who first, second, third ....... then arrange the whole multiple ranges

2- if I select different data then will arrange directly to data have already sorted (under data as in point1) bottom

3- if I select data have already sorted before then will arrange again and delete from old location and rise data have already existed to up
 
ok but after sorting from the first time
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1212BS 165 R13C R624 IND44
32CCR-1213BS 175/70R13 EP150 THI2
43CCR-1214BS 185/65R15 B250 JAP2
54CCR-1215BS 185/65R15 T001 JAP1
65CCR-1227BS 1400R20 TCF R180BZ JAP4
76CCR-1228BS 205/60R16 T005 THI8
87CCR-1218BS 195R14C R623 THI4
98CCR-1232BS 215/55R17 T005 JAP4
109CCR-1226BS 1400R20 TCF R180 JAP2
1110CCR-1231BS 215/50 R17 EP300 THI10
1211CCR-1216BS 195/75R16C R613 JAP6
1312CCR-1220BS 1200 R20 18PR G580 THI20
1413CCR-1233BS 215/60R16 ER30 JAP88
1514CCR-1221BS 1200 R20 18PR G580 JAP30471
1615CCR-1222BS 1200R20-18PR R187 JAP9
1716CCR-1223BS 1200R24 G580508
1817CCR-1224BS 1200R24 G5822
1918CCR-1225BS 13 R22.5 R187 JAP4
2019CCR-1211BS 1400R20VSJ TCF JAP2255
2120CCR-1217BS 195R14C 613 JAP4
2221CCR-1219BS 195R15C 613V JAP44
2322CCR-1229BS 205/70R15C R623 THI8405
2423CCR-1230BS 205R16C D840 THI26
2524CCR-1234BS 215/65R15 T005A IND44
REPORT

and when select another process as in example :cells A21,A15,A3

will be wrong sorting
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1212BS 165 R13C R624 IND44
32CCR-1214BS 185/65R15 B250 JAP2
43CCR-1215BS 185/65R15 T001 JAP1
54CCR-1227BS 1400R20 TCF R180BZ JAP4
65CCR-1228BS 205/60R16 T005 THI8
76CCR-1218BS 195R14C R623 THI4
87CCR-1217BS 195R14C 613 JAP4
98CCR-1221BS 1200 R20 18PR G580 JAP30471
109CCR-1213BS 175/70R13 EP150 THI2
1110CCR-1232BS 215/55R17 T005 JAP4
1211CCR-1226BS 1400R20 TCF R180 JAP2
1312CCR-1231BS 215/50 R17 EP300 THI10
1413CCR-1216BS 195/75R16C R613 JAP6
1514CCR-1220BS 1200 R20 18PR G580 THI20
1615CCR-1233BS 215/60R16 ER30 JAP88
1716CCR-1222BS 1200R20-18PR R187 JAP9
1817CCR-1223BS 1200R24 G580508
1918CCR-1224BS 1200R24 G5822
2019CCR-1225BS 13 R22.5 R187 JAP4
2120CCR-1211BS 1400R20VSJ TCF JAP2255
2221CCR-1219BS 195R15C 613V JAP44
2322CCR-1229BS 205/70R15C R623 THI8405
2423CCR-1230BS 205R16C D840 THI26
2524CCR-1234BS 215/65R15 T005A IND44
REPORT

but the right way should be
Elmarghanie Brand .xlsm
ABCDE
1ITEMCODEBRANDPURCHASESELLING
21CCR-1212BS 165 R13C R624 IND44
32CCR-1214BS 185/65R15 B250 JAP2
43CCR-1215BS 185/65R15 T001 JAP1
54CCR-1217BS 195R14C 613 JAP4
65CCR-1221BS 1200 R20 18PR G580 JAP30471
76CCR-1213BS 175/70R13 EP150 THI2
87CCR-1227BS 1400R20 TCF R180BZ JAP4
98CCR-1228BS 205/60R16 T005 THI8
109CCR-1218BS 195R14C R623 THI4
1110CCR-1232BS 215/55R17 T005 JAP4
1211CCR-1226BS 1400R20 TCF R180 JAP2
1312CCR-1231BS 215/50 R17 EP300 THI10
1413CCR-1216BS 195/75R16C R613 JAP6
1514CCR-1220BS 1200 R20 18PR G580 THI20
1615CCR-1233BS 215/60R16 ER30 JAP88
1716CCR-1222BS 1200R20-18PR R187 JAP9
1817CCR-1223BS 1200R24 G580508
1918CCR-1224BS 1200R24 G5822
2019CCR-1225BS 13 R22.5 R187 JAP4
2120CCR-1211BS 1400R20VSJ TCF JAP2255
2221CCR-1219BS 195R15C 613V JAP44
2322CCR-1229BS 205/70R15C R623 THI8405
2423CCR-1230BS 205R16C D840 THI26
REPORT
 
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.
I think I found the problem. Paste this code to Module and reopen the file again. If it doesn't work, maybe you should start a new thread.
VBA Code:
Public mySelection() As Long, counter As Long
Sub mySort()
  Dim i As Long, cellRow As Long, offsetVal As Integer
  Application.ScreenUpdating = False
  With Worksheets("REPORT")
  For Each sel In mySelection
    cellRow = Application.Match(sel, .Range("A:A"), 0)
    On Error Resume Next
    offsetVal = IIf(counter + 1 > cellRow, 2, 1)
    Application.CutCopyMode = False
    .Cells(cellRow, 1).Resize(, 5).Cut
    .Cells(counter + 1, 1).Offset(offsetVal).Insert Shift:=xlDown
    .Cells(counter + 1, 1).Offset(2).Copy
    .Cells(counter + 1, 1).Offset(1).PasteSpecial xlFormats
    Application.CutCopyMode = True
    On Error GoTo 0
    counter = counter + 1
  Next
  For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row - 1
    .Cells(i + 1, 1).Value = i
  Next
  .Cells(counter + 1, 1).Select
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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