Quick Excel Macro 30.01.08
I need a macro that does the following:
I have a list of data in a single column and need to filter and format the data and then return the formatted data into a new column.
Here are the 3 user inputs: the data, Character limit (x), and the word filters list. The data is a list of sentences in a single column., x is just a number - spaces and numbers count as characters too, and the word filters list is a list of words in a single column.
The program will go through and see if each sentence is greater than my Character limit (x).
For sentences that are NOT greater or EQUAL to the set character limit (x), the program will just leave these sentence alone.
For sentences that are Greater than the set character limit (x), the program needs to format the sentence by doing the following:
1. Check to see if the sentence contains the first word in my filtered list.
2. If the sentence contains the first filtered word, the word is deleted from the sentence.
3. Check the sentences again if they meet the character limit (x)
4. For the ones that do not meet the char limit after this first pass, the program will check the second filter word on the list and remove that word from these remaining sentences.
5. The program will do this until all the sentences have been formatted through the filter list
6. After going through the filtered word list, there will still be sentences that exceed the character limit. For these sentences, the program will remove the last word in each sentence until the data meets the character limit.
For example my sentence data is
johnny has a black dog that eats all day long
john kim had a big cat that sleeps all day long
jon sleeps
12345 ab is a company that had the product
Character limit: x is set to 10
Filter words list:
a
black
that
Result:
johnny has
john kim
jon sleeps
12345 ab
Please post in PMB.
Thanks.



