Notifications
Clear all

VBA insert symbol unicode

3 Posts
2 Usuários
0 Reactions
1,185 Visualizações
(@miguexcel)
Posts: 167
Reputable Member
Topic starter
 

Olá a todos,

Estou perante um problema que até ao momento não consegui resolver.

Pretendo inserir simbolos unicode em uma célula, mas quando tento fazê-lo em VBA não funciona. Alguem sabe como resolver? Pretendo adicionar simbolos como por exemplo:

ś -> Character code (015B)
ź -> Character code (017C)

Podem-me ajudar?

 
Postado : 04/05/2017 4:38 am
(@osvaldomp)
Posts: 857
Prominent Member
 
Sub teste()
 [A1] = ChrW(&H15B)
 [A2] = ChrW(&H17C)
End Sub

Se você quer o "z" com acento agudo então o código é 17A em lugar do 17C

 
Postado : 04/05/2017 5:21 am
(@miguexcel)
Posts: 167
Reputable Member
Topic starter
 

Obrigado Osvaldomp. Já agora, existe forma de optimizar este código? Estou a fazer isto só para uma coluna mas preciso para 33 colunas, o que torna o código muito lento. O workbook tem cerca de 100.000linhas.

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False
Application.EnableEvents = False

 For i = 1 To 94694
  If Cells(i, 1) = "existCharacter" Then
    With Cells(i, 4)
    .Replace What:="œ", Replacement:=ChrW(&H15B), MatchCase:=True
    .Replace What:="³", Replacement:=ChrW(&H142), MatchCase:=True
    .Replace What:="¿", Replacement:=ChrW(&H17C), MatchCase:=True
    .Replace What:="Ÿ", Replacement:=ChrW(&H17A), MatchCase:=True
    .Replace What:="¹", Replacement:=ChrW(&H105), MatchCase:=True
    .Replace What:="¯", Replacement:=ChrW(&H17C), MatchCase:=True
  End With
  End If
 Next i

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
 
Postado : 04/05/2017 6:04 am