I am working with a large data file. B column of the excel sheet contains files names. However during download 2 characters get replaced (ä becomes +ñ and ö becomes +Â.) I need to be able to search with these file names so I need to reverse the names back to original.
Here is what I originally tried:
Private Sub scandit(n As Long)
Dim i As Long
For i = 2 To n
Dim a As String
Dim b As String
Dim c As String
Dim d As String
a = "+" & ChrW(194) ' +
b = ChrW(132) 'ä
c = "+" & ChrW(164) ' +n
d = ChrW(148) 'ö
If Not IsEmpty(Cells(i, 2).Value) Then
Cells(i, 2).Value = Replace(Cells(i, 2).Value, c, b)
Cells(i, 2).Value = Replace(Cells(i, 2).Value, a, d)
End If
Next i
End Sub
However this doesn't work. "+ñ" only gets removed but not replaced. Nothing happens to "+Â".
After some googling I found this:
Sub CommandButton1_Click()
Dim fnd As Range
With ActiveSheet
.Cells.Replace what:="+" & ChrW(194), replacement:=ChrW(132),
lookat:=xlPart
.Cells.Replace what:="+" & ChrW(164), replacement:=ChrW(148),
lookat:=xlPart
End With
End Sub
This has the exact same problem as my own code.
Example on how the replacement should work: sy+Âd+ñ -> syödä
It would be much appreciated if someone had some ideas on how to proceed here (note that I want to do the replacement only for cells in B column.)