Gruppe
Allgemein
Problem
Die Gesellschaftszusätze eines Firmennamens sollen geprüft und ggbf. Korrigiert werden.
StandardModule: basMain
Sub CoReplace()
Dim arr As Variant
Dim iCounter As Integer, iStart As Integer
Dim sCompany As String
arr = Array("KG", "AG", "KG a.A.", "GmbH", "Co.")
sCompany = Range("A1").Value
For iCounter = 0 To 4
iStart = InStr(1, sCompany, " " & arr(iCounter), 1)
If iStart > 0 Then
Mid(sCompany, iStart + 1) = arr(iCounter)
End If
Next iCounter
If MsgBox( _
prompt:=sCompany, _
Buttons:=vbQuestion + vbOKCancel _
) = vbOK Then
Range("A1").Value = sCompany
End If
End Sub