E
ExcelLars
Is it possible to do this with less code?
EmneRensket = Rensket(Emne, ":")
EmneRensket = Rensket(Emne, ";")
EmneRensket = Rensket(Emne, ".")
EmneRensket = Rensket(Emne, ",")
EmneRensket = Rensket(Emne, "\")
EmneRensket = Rensket(Emne, "/")
EmneRensket = Rensket(Emne, "*")
EmneRensket = Rensket(Emne, "[")
EmneRensket = Rensket(Emne, "]")
EmneRensket = Rensket(Emne, "?")
EmneRensket = Rensket(Emne, "!")
EmneRensket = Rensket(Emne, "'")
EmneRensket = Rensket(Emne, "<")
EmneRensket = Rensket(Emne, ">")
EmneRensket = Rensket(Emne, "|")
Function Rensket(text As String, illegal As String) As String
Dim Ch As String
For i = 1 To Len(illegal)
Ch = Mid(illegal, i, 1)
While InStr(text, Ch) > 0
text = Left(text, InStr(text, Ch) - 1) & Right(text, Len(text)
- InStr(text, Ch))
Wend
Next
Rensket = text
End Function
EmneRensket = Rensket(Emne, ":")
EmneRensket = Rensket(Emne, ";")
EmneRensket = Rensket(Emne, ".")
EmneRensket = Rensket(Emne, ",")
EmneRensket = Rensket(Emne, "\")
EmneRensket = Rensket(Emne, "/")
EmneRensket = Rensket(Emne, "*")
EmneRensket = Rensket(Emne, "[")
EmneRensket = Rensket(Emne, "]")
EmneRensket = Rensket(Emne, "?")
EmneRensket = Rensket(Emne, "!")
EmneRensket = Rensket(Emne, "'")
EmneRensket = Rensket(Emne, "<")
EmneRensket = Rensket(Emne, ">")
EmneRensket = Rensket(Emne, "|")
Function Rensket(text As String, illegal As String) As String
Dim Ch As String
For i = 1 To Len(illegal)
Ch = Mid(illegal, i, 1)
While InStr(text, Ch) > 0
text = Left(text, InStr(text, Ch) - 1) & Right(text, Len(text)
- InStr(text, Ch))
Wend
Next
Rensket = text
End Function