我想查找「#」字符,將其移除並在其後標上2個字符。 I`ve得到這個代碼:Excel/vba查找字符,替換後再替換爲兩個字符
pos = InStr(mycell.Value, "#")
If pos > 0 Then
mycell.Replace What:="#", Replacement:=""
mycell.Characters(Start:=pos + 1, Length:=2).Font.Superscript = True
End If
當我只能更換 - 工程。當我只製作一些字體上標 - 作品。當兩者 - 只有替換。
什麼版本的Excel?此外,你有沒有嘗試過'mycell.Characters(開始:= pos,長度:= 2).Font.Superscript = True'('pos'而不是'pos' + 1)? – LittleBobbyTables
@LittleBobbyTables是正確的 - 在用'「替換'#'後,你想要上標的字符位於'pos'和'pos + 1'。如果它們是字符串中的最後兩個字符,那麼可能會出現「無聲錯誤」,並且沒有任何反應。 – Floris