View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jos Vens[_2_] Jos Vens[_2_] is offline
external usenet poster
 
Posts: 134
Default Substitute chr(39)

Hi,

I made function (see below) to substitute mistake input into right input

eg. when I type the letter O, I substitute in zero 0

I also like to let the laptop-user (AZERTY-keyboard layout) use the upper
row of the keyboard without shift pressed in to get figures so I substitute
& by 1, é by 2 etc.

Everything works fine, except for 4 because the ' sign (chr(39)) is used to
tell excel this is text. I cannot substitute ' in 4 if it is in the
beginning of my input (I works right for (' to make 54 but not '( in 45)

Can anyone help to substitute ' in 4 when it's in the beginning of my input?

Thanks,
Jos Vens

Here goes my code

Function SET_Value(vInput As Range)

Dim vSubstitute

vSubstitute = vInput
vSubstitute = WorksheetFunction.Substitute(vSubstitute, ",", ".")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "O", "0")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "o", "0")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "_", "-")

vSubstitute = WorksheetFunction.Substitute(vSubstitute, "&", "1")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "é", "2")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, """", "3")

vSubstitute = WorksheetFunction.Substitute(vSubstitute, Chr(39), "4")
'vSubstitute = WorksheetFunction.Substitute(vSubstitute, "'", "4") '-does
not work either

vSubstitute = WorksheetFunction.Substitute(vSubstitute, "(", "5")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "§", "6")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "è", "7")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "!", "8")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "ç", "9")
vSubstitute = WorksheetFunction.Substitute(vSubstitute, "à", "0")

vInput = vSubstitute

End Function