Sort problem

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,132
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
I have this data and i have the script for sort.

It is not giving me the correct sort not sure why. any help

Cell Formulas
RangeFormula
M7:Q7M7=E7
L8:L21,L23:L32L8=IF(D8="","",D8)
M8:M21,M23:M32M8=IF(L8="","",COUNTIFS('cst cc Data'!$K:$K,L8,'cst cc Data'!$E:$E,$M$6))
N8:N21,N23:N32N8=IF(L8="","",COUNTIFS('cst cc Data'!$K:$K,L8,'cst cc Data'!$E:$E,$N$6))
O8:O21,O23:O32O8=IF(L8="","",COUNTIFS('cst cc Data'!$K:$K,L8,'cst cc Data'!$E:$E,$O$6))
P8:P21,P23:P32P8=IF(L8="","",COUNTIFS('cst cc Data'!$K:$K,L8,'cst cc Data'!$E:$E,$P$6))
Q8:Q21,Q23:Q32Q8=IF(L8="","",COUNTIFS('cst cc Data'!$K:$K,L8,'cst cc Data'!$E:$E,$Q$6))


output with script
FTTH_Customer_Complains_Weekly_V1.xlsm
BLBMBNBOBPBQ
2HAYw-21w-22w-23w-24w-25
3
4
5
6
7
8
9
10
11
12
13
14
15
16RIYADH_Yasmeen10863
17RIYADH_Al Nadhim00112
18RIYADH_As Sahafah03242
19RIYADH_Dherat Al Laben02032
20RIYADH_Ishbiliyyah10341
21RIYADH_Al Yarmuk13611
22RIYADH_Al Munsiyah01101
23RIYADH_Al Malqa02711
24RIYADH_Tuwaiq21120
25000000
26RIYADH_Al Qadisiyah00000
27JEDDAH_Bani Malik00000
Graphs


VBA Code:
With targetSheet.Sort
        .SortFields.Clear
        .SortFields.Add Key:=targetSheet.Range("BQ2:BQ27"), _
              SortOn:=xlSortOnValues, _
              Order:=xlDescending, _
              DataOption:=xlSortNormal
        .SetRange targetCellclean
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
End With
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Well give an example of what the correct sort would look like as we in the dark on your desired outcome
 
Upvote 0
Book5
BLBMBNBOBPBQ
1HAYw-21w-22w-23w-24w-25
2RIYADH_Yasmeen10863
3RIYADH_Al Nadhim00112
4RIYADH_As Sahafah03242
5RIYADH_Dherat Al Laben02032
6RIYADH_Ishbiliyyah10341
7RIYADH_Al Yarmuk13611
8RIYADH_Al Munsiyah01101
9RIYADH_Al Malqa02711
10RIYADH_Tuwaiq21120
11RIYADH_Al Qadisiyah00000
12JEDDAH_Bani Malik00000
Sheet1




this is the correct short with large to small for BQ
 
Upvote 0
In .SetRange targetCellclean, TargetCellclean has to be a range where is it defined ?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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