SOLVED

Data sorting

Copper Contributor

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 able to copy and paste the data but it takes a significant amount of time to sort through as the sequence is

TrackbCAM1, TrackbCAM2, TrackbCAM3, TrackbCAM4, trackbsphere, TrackcCAM1, TrackcCAM2, TrackcCAM3 etc....

 

Does anyone know a quick way to sort this in excel? Any help would be very much appreciated.

thanks 

9 Replies
best response confirmed by AndrewEastop (Copper Contributor)
Solution

@AndrewEastop 

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:

 

S0432.png

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.

Thank you very much Hans

Would anyone know how to get the file path to show in numerical order for this data also?

At the moment it goes 1,10,100,1000, 1001,1002 etc but I would rather it went 1,2,3,4,5... 

I tried the az sort button but nothing changed 😞

thanks 

Andrew 

@AndrewEastop 

See the attached version, now a .xlsm. You will have to allow macros.

I have already run the FixNum macro on columns C, F, ...

Great job Hans, thank you very much! How exactly did you do it lol?

@AndrewEastop 

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.

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 

@AndrewEastop 

See the attached version. The macro FixNumbers will now do it all.

thank you Hans!
1 best response

Accepted Solutions
best response confirmed by AndrewEastop (Copper Contributor)
Solution

@AndrewEastop 

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:

 

S0432.png

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.

View solution in original post