i have created a sheet to paste in text and output lower, UPPER, and Proper text I have a named range of prepositions and articles capitalizerd.

I am trying to use the SUBSTITUTE formula to replace all the occurrences or words that appear in the prepositions list

so instead of

Our Breakfast Is Consistent

We get

 Our Breakfast is Consistent

so far I have this formula, but it does not work

=SUBSTITUTE(D6, TRIM(prepositions), TRIM(LOWER(prepositions))

Can anyone help. Would be very appreciated

Thanks

Andi

有帮助吗?

解决方案

I would create a user defined function

   Function prep_lower(the_text)

    Dim prep_list(10, 10)

    prep_list(1, 1) = "As"
    prep_list(1, 2) = "as"

    prep_list(2, 1) = "Or"
    prep_list(2, 2) = "or"

    prep_list(3, 1) = "Is"
    prep_list(3, 2) = "is"
    'more items......


    For n = 1 To UBound(prep_list, 1)
    the_text = Application.WorksheetFunction.Substitute(the_text, Chr(32) & prep_list(n, 1) & Chr(32), Chr(32) & prep_list(n, 2) & Chr(32))
    Next 'For n = 0 To...

    prep_lower = the_text



    End Function

then enter text in, say, cell a1 and the formula =prep_lower(A1) in b1

其他提示

You can't use SUBSTITUTE to replace lists in one hit - you need to SUBSTITUTE one item at a time, so if you have prepositions in F2:F5, for example you could use a formula like

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D6,F2,LOWER(F2)),F3,LOWER(F3)),F4,LOWER(F4)),F5,LOWER(F5))

Of course if you have a long list that isn't very practical, in which case you could possibly copy down (or across) a formula which would potentially replace one value at a time, e.g. with the above example use this formula in D7 to D10

=SUBSTITUTE(D6,F2,LOWER(F2))

D10 will be the final value with all substitutions

I figured it's easier to do this in PHP rather than excel. Set up a form with options and use some regular expressions to output the kind of text I need.

I will once I have created the HTML and PHP will post the example here. I will also do it as an option to upload a CSV, read from it and then it will output in a way you can see. With an export back to CSV with amends.

This might be useful then for anyone facing the same problem.

Thank you to the kind users who posted solutions to this problem I had.

Thanks

Andi

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top