If - Const - Speicherortwahl
19.05.2021 11:15:50
Newtron
ich hoffe auf Hilfe.
Ich habe per Schaltfläche_Klick ein Script gebaut, dass automatisch nach Namenskonvention speichert.
Bisher hatte ich folgenden VBA Code :
Const myPath = "\\FirmaXY\Personal\"
ThisWorkbook.SaveAs myPath & Format(Date, "yyyymmdd") & "-" & Range("B19") & ".xls"
Nun möchte ich eine Auswahl schaffen (dafür gibt es in Range B14 ein Dropdown, in Range B19 steht der Nachname des Mitarbeiters).Ich habe folgendes gebaut und habe da jetzt wegen der "Const" Probleme:
If Range("B14") = "Vertrieb" Then
Const myPath = "\\FirmaXY\Vertrieb\"
ThisWorkbook.SaveAs myPath & Format(Date, "yyyymmdd") & "-" & Range("B19") & ".xls"
Else
Const myPath = "\\FirmaXY\Personal\"
ThisWorkbook.SaveAs myPath & Format(Date, "yyyymmdd") & "-" & Range("B19") & ".xls"
End If
Wie ändere ich es so, dass das Konstanten Problem mit der beiden Speicherorten gelöst wird?Grüße
Newtron