AW: Lösung gefunden
21.06.2018 08:45:47
UweD
Hallo
ich würde es so machen
Sub Test_Dateiname_ändern()
Dim Tb, Pfad As String, Alt(3) As String, Neu(3) As String
Dim i As Integer, EZ As Integer, ES As Integer
Pfad = "C:\Users\Peter\Desktop\Test_2018_06_20_Dateinamen\"
EZ = 4 'erste Zeile
ES = 4 'erste Spalte
Set Tb = Worksheets("Tabelle1")
For i = 0 To 2
Alt(i) = Tb.Cells(EZ, ES).Offset(i, 0)
Neu(i) = Tb.Cells(EZ, ES).Offset(i, 1)
If Alt(i) <> "" Then
If Neu(i) <> "" Then
If Dir(Pfad & Alt(i)) <> "" Then
If Dir(Pfad & Neu(i)) = "" Then
Name Pfad & Alt(i) As Pfad & Neu(i)
Else
MsgBox Neu(i) & " gibt es schon." 'neu schon da
End If
Else
MsgBox Alt(i) & " nicht vorhanden." 'Alt nicht da
End If
Else
MsgBox "Ungültiger Name in " & Cells(EZ + i, ES + 1).Address 'Neu ist leer
End If
Else
MsgBox "Ungültiger Name in " & Cells(EZ + i, ES).Address 'Alt ist leer
End If
Next
End Sub
LG UweD