Thema Datum  Von Nutzer Rating
Antwort
02.02.2016 16:18:19 kaba
NotSolved
02.02.2016 17:43:50 BigBen
NotSolved
02.02.2016 18:12:36 kaba
NotSolved
02.02.2016 18:40:11 BigBen
NotSolved
02.02.2016 19:24:42 BigBen
NotSolved
02.02.2016 19:43:53 BigBen
NotSolved
02.02.2016 22:24:10 kaba
NotSolved
03.02.2016 10:18:19 BigBen
NotSolved
03.02.2016 12:15:47 kaba
NotSolved
03.02.2016 17:40:51 BigBen
NotSolved
03.02.2016 17:45:07 BigBen
NotSolved
Blau Alternative
03.02.2016 15:06:47 Gast90145
NotSolved
03.02.2016 15:14:37 Gast61811
NotSolved
03.02.2016 15:47:43 Gast59525
NotSolved
03.02.2016 16:31:57 Tim
NotSolved

Ansicht des Beitrags:
Von:
Gast90145
Datum:
03.02.2016 15:06:47
Views:
540
Rating: Antwort:
  Ja
Thema:
Alternative

Option Explicit

'Schaltfläche (Button) verweist auf dieses Makro

Sub ChkBeforeSave()
Const OrdnerPfad As String = "y:\Nachkalkulation\"     'ggf. ändern
Const PfadZelle As String = "C1"                   '
Const KdNrZelle As String = "E1"                   '
'
Dim flag, chk                                      'alles richtig?
Dim strFullname As String                          'speichern als
'
On Error GoTo Fehler
'Prüfung auf OrdnerPfad in Pfadzelle
With Range(PfadZelle)
   chk = .Value * 1
   If Len(Trim(.Formula)) = 8 Then flag = True
End With
'Prüfung auf Kundennummer in KdNrZelle
With Range(KdNrZelle)
   chk = .Value * 1
   If Len(Trim(.Formula)) <> 5 Then flag = False
End With
On Error GoTo 0
Fehler:
'Auswerten
Select Case Err.Number
   Case 0
      If flag = True Then
         On Error GoTo LW
         Application.DisplayAlerts = False
         strFullname = OrdnerPfad & Format(Range(PfadZelle).Formula, String(8, "0")) & ".xlsx"
         ActiveWorkbook.SaveAs Filename:=strFullname, FileFormat:=xlOpenXMLWorkbookMacroEnabled
         On Error GoTo 0
      Else
         Call MsgBox("Eingabelängen in " & _
         "PfadZelle" & " bzw. " & "KdNrZelle" & " prüfen!", vbExclamation, "Abbruch")
      End If
   Case 13
      Call MsgBox("Eingaben in " & _
         "PfadZelle" & " bzw. " & "KdNrZelle" & " sind keine Ziffern!", vbExclamation, "Abbruch")
   Case Else
      Call MsgBox("Unbekannter Fehler!", vbExclamation, "Abbruch")
End Select
LW:
If Err.Number = 1004 Then _
   Call MsgBox("Speicherpfad?" & Chr(10) & "Einstellungen im Makro prüfen!", vbExclamation, "Abbruch")
Application.DisplayAlerts = True
End Sub


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
02.02.2016 16:18:19 kaba
NotSolved
02.02.2016 17:43:50 BigBen
NotSolved
02.02.2016 18:12:36 kaba
NotSolved
02.02.2016 18:40:11 BigBen
NotSolved
02.02.2016 19:24:42 BigBen
NotSolved
02.02.2016 19:43:53 BigBen
NotSolved
02.02.2016 22:24:10 kaba
NotSolved
03.02.2016 10:18:19 BigBen
NotSolved
03.02.2016 12:15:47 kaba
NotSolved
03.02.2016 17:40:51 BigBen
NotSolved
03.02.2016 17:45:07 BigBen
NotSolved
Blau Alternative
03.02.2016 15:06:47 Gast90145
NotSolved
03.02.2016 15:14:37 Gast61811
NotSolved
03.02.2016 15:47:43 Gast59525
NotSolved
03.02.2016 16:31:57 Tim
NotSolved