Thread: [Solved] Sort Filter Problem
View Single Post
 
Old 01-26-2022, 07:02 PM
p45cal's Avatar
p45cal p45cal is offline Windows 10 Office 2019
Expert
 
Join Date: Apr 2014
Posts: 956
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

You have 1 or 2 zero-width space characters at the left of many of your cells in the Country column. See Sheet1 (2) of the attached where I've deleted the other columns and added a formula to the right to show each character's unicode from those cells.
Those with 8203 are the zero-width spaces; 2 in front of TANZANIA and plenty of others.
They shouldn't be there and have come in as a result of how you brought the data into Excel (a copy/paste from a website?).
How to remove:
1. Best not to bring them in in the first place if possible - perhaps use Power Query to get that data?
2. Remove them in situ and en masse with a line of vba:
  • Select the cells on the sheet you want to clean up.
  • Go to the Immediate Pane of the VBE (keyboard: press Alt+F11 then Ctrl + G)
  • type and execute this line of code:
selection.Replace What:=ChrW(8203), Replacement:="", LookAt:=xlPart
Test it on column C of Sheet1 (2) of the attached first.
Then your sorting should be fine.
Attached Files
File Type: xlsx msofficeforums48388Excel_Problem_1.xlsx (101.4 KB, 9 views)
Reply With Quote