Fortan code start on mfix

Hello everyone,
After simulating particle falls, I would like to sort these particles with the following code:
Sub real vib()
'Sorting Macro
Dim NbParticles As Long
MbParticles ActiveSheet.UsedRange.Rows.Count
"MsgBox NbParticles
'Delete the particles above the 30deg slope
For 1 To NbParticles
If Cells (i, 2) .Value >0.053345 - Sqr(3)/3*Cells(i,1) .Value Then
Rows(1).ClearContents
End If
Next i
[A:A].SpecialCells(xlCellTypeBlanks) EntireRow.Delete
'Change the diameter litle bit to have different color of particle
NbParticles = ActiveSheet.UsedRange.Rows.Count
For i=1 To NbParticles
If (Cells(i, 1).Value < -0.236 + 0.075) Or (Cells (i,1).Value >-0.236+0.15 And Cells (i,1).Value <-0.236 + 0.225)
Or (Cells(i, 1).Value > -0.236 + 0.3)And(Cells(i, 1).Value < 0.0236 + 0.375 Then
Cells (i,4)=0.01
Else
Cells(1, 4) = 0.0101
End If
Next i
Range (Cells(1, 1), Cells (nbLignes, 4)).Copy
MegBox nbLignes
End Sub

Where do I integrate this code and how do I run it so that Mfix sorts the particles after simulating particle falls?
Thanks for your help !

First, you would need to write the equivalent code in Fortran, not VBA. Then you could put your code in usr3.f, which is called at the end of the run. Copy usr3.f in your project directory and rebuild the solver. When you run the simulation, select the project directory instead of the default solver.

10. User-Defined Functions — MFiX 24.1 documentation (doe.gov)

Thanks for your advice.