Hello everyone,
I need a macro which does following for the selected area:
1a. Step
Each "§" should be replaced by "µ" in whole document but not those which are followed by "." or ";" or "»" or "«" or "(" or ")" or followed by space.
1b. Step
Change the color of new added "µ" to red.
2. Step
Each "~" should be replaced by "&" but not those which have "." or ";" or "»" or "«" or "(" or ")" or space befor it.
2b. Step
Change the color of new added "&" to red.
3. Step
Show message how many "§" and how many "~" were added.
Example:
Germa§ vot§r§. ~a~e re~ §av~.
should become:
Germa§ votµr§. ~a&e re& §av&.
Thank you very much for each assistance in advance.
Posted in Word programming area as well:
Last edited by wali; 09-30-2009 at 11:04 AM.
I've made a Custom Function. I can't get the red right yet, but here is the intermediate solution:
If the String is in A1 then place this formulaFunction ReplaceStr(SourceStr As Range) As String '"§" replaced by "µ" not those which are followed by "." or ";" or "»" or "«" or "(" or ")" or followed by space. '"~" replaced by "&" "." or ";" or "»" or "«" or "(" or ")" or space before it. Dim TmpChar As String, TmpBefore As String, TmpAfter As String ReplaceStr = "" For CharCounter = 1 To Len(CStr(SourceStr)) 'Loop through characters in string TmpChar = Mid(CStr(SourceStr), CharCounter, 1) If CharCounter > 1 And CharCounter < Len(SourceStr) Then TmpBefore = Mid(SourceStr, CharCounter - 1, 1) TmpAfter = Mid(SourceStr, CharCounter + 1, 1) ElseIf CharCounter = 1 Then TmpBefore = "" TmpAfter = Mid(SourceStr, CharCounter + 1, 1) ElseIf CharCounter = Len(SourceStr) Then TmpBefore = Mid(SourceStr, CharCounter - 1, 1) TmpAfter = "" End If Select Case TmpChar Case "§" Select Case TmpAfter Case ".", ";", "»", "«", "(", ")", " " 'Do Nothing Case Else TmpChar = "µ" End Select Case "~" Select Case TmpBefore Case ".", ";", "»", "«", "(", ")", " " 'Do Nothing Case Else TmpChar = "&" End Select Case Else 'Do Nothing End Select ReplaceStr = ReplaceStr & TmpChar Next CharCounter End Functionin another cell=ReplaceStr(A1)
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Thank you very much. It works very good. I need this for MS word. Is it possible to have the same function as makro for MS word or for Excel?
Thank you very much
This is an excel forum, so maybe you have to post the same request at a word forum.
Looking for great solutions but hate waiting?
Seach this Forum through Google
www.Google.com (e.g. +multiple +IF site:excelforum.com/excel-general/ )
www.Google.com (e.g. +fill +combobox site:excelforum.com/excel-programming/ )
Ave,
Ricardo
Ok! Thank you very much. It works perfect in excel.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks