"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Remember that we can't run your code with your data: we have no access to either!
So assuming it's not a syntax error (in which case we have no idea what your code is meant to do, much less any way to run it and guess) it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. See here:
VBA – Debug.Print and the Immediate Window - Automate Excel[
^] and here:
https://www.bluepecantraining.com/portfolio/excel-vba-debugging-techniques/[
^]
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!