So, like the title says... I think
Let me explain the situation a little bit:
I've made a compiler that takes a bunch of files. All the files are supposed to be named something like 123456 - Q.ABC-A - Person's Name.txt
Problem I'm facing is that it seems like people can't seem to follow simple instructions, and I end up with files with names like 123456-Q.ABC-A-Person's Name.txt, which was easy to get around in my code by removing spaces as each file is processed and then adding them where I actually want them, which is around the first and third Hyphens.
My problem is the people that seem to have a harder time following instructions and I end up with files named something like 123456 - Q.ABC.A - Person's Name.txt or 123456 - Q.ABC-A Person's Name.txt, and have even had people using em dashes instead of hyphens and any number of other things that throws wrenches into my code.
I've been reading about things like using the "like" function, but that would only return true or false on whether or not the string matches the pattern, right? I'd still have to try and guess all the ways someone might mess up naming their file.
TL;DR
Is there a way to code a macro so that it will force a string into a specified pattern? So that I always get 123456 - Q.ABC-A - Person's Name.txt no matter if someone replaces a dot for a hyphen or a hyphen for a dot or whatever else they might do?
I'm trying to figure out how to import all the files and have the string get formatted to the proper pattern no matter how people seem to try and break things by naming things wrong without having to try and guess all the ways they might try to do so ahead of time.
Note:
- 123456 isn't always a six digit number. Sometimes there are less, but 6 should be the max.
- Sometimes the Q.ABC.A part has a double letter such as Q.ABC-AA
Thanks in advance for any help. I've been wracking my brain over this for a while. I'm no VBA pro, so I thought it was about time I asked for some help.
Bookmarks