Forum Discussion
AndrewEastop
May 21, 2021Copper Contributor
Data sorting
Hello everyone, I have a very long list of data showing image file path names from multiple folders. I want to be able to sort this data into five columns (CAM1,CAM2,CAM3,CAM4 and Sphere). I am ab...
- May 21, 2021
If you have Excel in Microsoft 365, you can use the new FILTER function for this.
Otherwise, Advance Filter (Data tab of the ribbon > Advanced) is a quick way to do this.
First, insert a header in A1. I used File, but it can be anything.
Set up a criteria range: File in cell C1 (spelled exactly as in A1) and *CAM1* in C2.
Also set up a copy-to range: File in cell D1 (as in A1).
Select A1 and click Advanced.
Ignore the warning that Excel puts up.
Specify the criteria range, select 'Copy to another range' and specify the Copy to range:
Click OK.
Do the same for the other cameras. It took me less time to execute than to write this down.
See the attached version.
HansVogelaar
May 24, 2021MVP
The macro loads a column into an array in memory.
It then uses string functions such as InStr, Left, Mid and Format to expand the numbers after the camera such as 1, 12, 103 to four digits: 0001, 0012, 0103.
The new values are written to the column to the right. The two columns are sorted on the second column (the one with the expanded numbers).
Finally, that second column is cleared again.
Because array operations are relatively fast, the macro only takes a few seconds to run.
You can view the code in the Visual Basic Editor.
AndrewEastop
May 27, 2021Copper Contributor
Is there a way in which I join two macros together to make one? I have made your first solution into a macro aswell and thought it would make things very simply if i was able to join them together!
thanks
Andrew
- AndrewEastopJun 01, 2021Copper Contributorthank you Hans!
- HansVogelaarMay 27, 2021MVP
See the attached version. The macro FixNumbers will now do it all.