Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
372to376
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
372to376
372to376
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

per vba Zellenabhängig Speicherort bestimmen

per vba Zellenabhängig Speicherort bestimmen
31.01.2004 13:31:34
Y. Housein
Hallo Leute,
ich habe 3 Ordner erstellt: C:\Rechnung ; C:\Lieferschein ; C:\Angebot.
Wie kann ich zellenabhängig Speicherort bestimmen. Z.B Wenn in Zelle A1 Rechnung steht dann möchte ich das das es in Ordner C:\Rechnung gespeichert wird. Wenn Lieferschein dann c:\lieferschein usw.
Ich hoffe Ihr könnt mir helfen.
Danke im voraus.
Y. Housein

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 13:43:53
Worti
Hallo Y,
so geht's:


Sub speichern()
Dim Speicherpfad As String
Speicherpfad = Cells(1, 1).Value
Speicherpfad = "C:\" & Speicherpfad
ChDir Speicherpfad
ActiveWorkbook.Save

End Sub

     Code eingefügt mit Syntaxhighlighter 2.5

Worti
Anzeige
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 14:17:48
Y. Housein
Hallo Worti,
danke für deine Hilfe - Klappt leider nicht. Anbei mein Code.
Dim dat As Date
Dim sPath As String
dat = Range("J18").Value 'J18 = Rechnungsdatum
sPath = "D:\Touren\Faktura\"
On Error Resume Next
MkDir sPath & Year(dat)
sPath = sPath & Year(dat) & "\"
MkDir sPath & Format(dat, "mm yyyy")
sPath = sPath & Format(dat, "mm yyyy") & "\"
ActiveSheet.Copy

ActiveWorkbook.SaveAs sPath & _
Range("j19").Value & " " & Range("J15") & " " & Range("E18") & _
" " & Format(dat, " dd-mm-yyyy") & ".xls"
ActiveWorkbook.Close
in Zelle J15 steht die Rechnungsart, d.h. Rechnung, Lieferschein oder Angebot. Also wenn in Zelle J15 Rechnung steht dann soll das nach D:\Touren\Faktura\Rechnungen gespeichert werden usw. Ich hoffe du hast mein Problem verstanden?
Gruß
Y. Housein
Anzeige
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 14:17:48
Y. Housein
Hallo Worti,
danke für deine Hilfe - Klappt leider nicht. Anbei mein Code.
Dim dat As Date
Dim sPath As String
dat = Range("J18").Value 'J18 = Rechnungsdatum
sPath = "D:\Touren\Faktura\"
On Error Resume Next
MkDir sPath & Year(dat)
sPath = sPath & Year(dat) & "\"
MkDir sPath & Format(dat, "mm yyyy")
sPath = sPath & Format(dat, "mm yyyy") & "\"
ActiveSheet.Copy

ActiveWorkbook.SaveAs sPath & _
Range("j19").Value & " " & Range("J15") & " " & Range("E18") & _
" " & Format(dat, " dd-mm-yyyy") & ".xls"
ActiveWorkbook.Close
in Zelle J15 steht die Rechnungsart, d.h. Rechnung, Lieferschein oder Angebot. Also wenn in Zelle J15 Rechnung steht dann soll das nach D:\Touren\Faktura\Rechnungen gespeichert werden usw. Ich hoffe du hast mein Problem verstanden?
Gruß
Y. Housein
Anzeige
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 14:48:03
Worti
Hallo Y,
hab dein Problem noch nicht ganz verstanden. Was funktioniert nicht?
Wenn du in D:\Touren\Faktura\Rechnungen speichern willst, füge vor dem Speichern doch die Zeilen

Speicherpfad = "D:\Touren\Faktura\" & Cells(15,10).Value
CHDir Speicherpfad
ActiveWorkbook.SaveAs ...

Worti
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 14:50:17
Y. Housein
Hi Worti,
stimmt Sorry - man muss den Hirn einschalten - dann klappt es meistens ;-)
Danke für deine Hilfe - Wünsche dir noch ein schönes Wochenende.
Gruß
Y. Housein
AW: per vba Zellenabhängig Speicherort bestimmen
31.01.2004 14:57:54
Josef Ehrensberger
Hallo Housein!
So sollte es klappen.


Sub Housein()
Dim dat As Date
Dim sPath As String
dat = Range("J18").Value 'J18 = Rechnungsdatum
sPath = "D:\Touren\Faktura\" & Range("J15") & "\"
On Error Resume Next
MkDir sPath & Year(dat)
sPath = sPath & Year(dat) & "\"
MkDir sPath & Format(dat, "mm yyyy")
sPath = sPath & Format(dat, "mm yyyy") & "\"
ActiveSheet.Copy
ActiveWorkbook.SaveAs sPath & _
Range("j19").Value & " " & Range("E18") & _
" " & Format(dat, " dd-mm-yyyy") & ".xls"
ActiveWorkbook.Close
End Sub

     Code eingefügt mit Syntaxhighlighter 2.5

Gruß Sepp
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige