Forum Discussion
Data sorting
- 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.
See the attached version, now a .xlsm. You will have to allow macros.
I have already run the FixNum macro on columns C, F, ...
- HansVogelaarMay 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.
- AndrewEastopMay 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
- HansVogelaarMay 27, 2021MVP
See the attached version. The macro FixNumbers will now do it all.