Thema Datum  Von Nutzer Rating
Antwort
22.05.2014 10:05:48 HR
NotSolved
22.05.2014 15:30:55 Amicro2000
NotSolved
22.05.2014 19:19:51 Gast64552
NotSolved
Blau Excelliste auf mehrere Blätter verteilen
22.05.2014 19:25:42 Gast19909
NotSolved
22.05.2014 20:50:25 Gast60763
*****
Solved
23.05.2014 13:10:06 HR
NotSolved
23.05.2014 13:31:25 Gast24605
*****
Solved
23.05.2014 13:10:06 HR
NotSolved
23.05.2014 16:50:19 HR
NotSolved
23.05.2014 17:15:11 Gast66050
Solved

Ansicht des Beitrags:
Von:
Gast19909
Datum:
22.05.2014 19:25:42
Views:
2364
Rating: Antwort:
  Ja
Thema:
Excelliste auf mehrere Blätter verteilen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Option Explicit
 
Public Sub SplitWorksheetByStoreID()
   
  If ActiveSheet Is Nothing Then Exit Sub
  If Not TypeOf ActiveSheet Is Excel.Worksheet Then Exit Sub
   
  If vbCancel = MsgBox("Die Daten, auf dem Aktiven Blatt, werden nun nach der 'store_id' aufgesplittet.", _
                      vbQuestion Or vbOKCancel Or vbDefaultButton2) _
  Then
    Exit Sub
  End If
   
  On Error GoTo ErrHandler
   
  Application.ScreenUpdating = False
   
  Dim wksDst As Excel.Worksheet
  Dim i As Long, j As Long
  Dim blnError As Boolean
   
  With Range("A1").CurrentRegion
     
    Call .Sort(Key1:=.Cells(1, "D"), Order1:=xlAscending, Header:=xlYes)
     
    i = 2
    Do Until i > .Rows.Count
       
      j = i
      Do While .Cells(i, "D") = .Cells(j + 1, "D")
        j = j + 1
      Loop
       
      If WorksheetExists(.Cells(i, "D").Text) Then
        Set wksDst = Worksheets(.Cells(i, "D").Text)
        Call wksDst.UsedRange.Delete
      ElseIf Not wksDst Is Nothing Then
        Set wksDst = ThisWorkbook.Worksheets.Add(After:=wksDst)
        wksDst.Name = .Cells(i, "D").Text
      Else
        Set wksDst = ThisWorkbook.Worksheets.Add(After:=.Worksheet)
        wksDst.Name = .Cells(i, "D").Text
      End If
       
      Call Union(.Rows(1), .Worksheet.Range(.Rows(i), .Rows(j))).Copy
      With wksDst.Range("A1")
        Call .PasteSpecial(xlPasteColumnWidths)
        Call .PasteSpecial(xlPasteValuesAndNumberFormats)
      End With
       
      On Error Resume Next
      Call GAForm
      blnError = blnError Or CBool(Err.Number)
      On Error GoTo ErrHandler
       
      i = j + 1
    Loop
     
    Call .Worksheet.Activate
     
  End With
   
  If Not blnError Then
    Call MsgBox("Vorgang erfolgreich abschlossen.", _
                vbInformation, _
                "Erfolg")
  Else
    Call MsgBox("Vorgang abschlossen." & vbNewLine & _
                "Während der Formatierung traten ein oder mehrere Fehler auf.", _
                vbExclamation, _
                "Erfolg")
  End If
   
SafeExit:
  Application.CutCopyMode = False
  Application.ScreenUpdating = True
Exit Sub
 
ErrHandler:
  Call MsgBox(Err.Description, _
              vbCritical, _
              "Fehler " & Err.Number)
  GoTo SafeExit
End Sub
 
Private Sub GAForm()
   
  Rows(1).ClearContents
   
  With Cells(3, 2).CurrentRegion
    With .Offset(-1, 0).Resize(.Rows.Count + 2)
      .Cells(1, 1).Value = 1
      .Cells(1, 1).Copy
      .SpecialCells(xlCellTypeConstants, 2).PasteSpecial xlPasteValues, operation:=xlMultiply
      .Rows(1).Value = Array("Datum", "Code", "Wert")
      .Columns(1).NumberFormat = "DD.MM.YYYY hh:mm"
      .Cells(.Rows.Count, 1).Value = "Summe"
      .Cells(.Rows.Count, 3).FormulaR1C1 = "=Sum(R[-" & .Rows.Count - 2 & "]C:R[-1]C)"
      .BorderAround Weight:=xlThin
      .Borders(xlInsideHorizontal).Weight = xlThin
      .Borders(xlInsideVertical).Weight = xlThin
      .Rows(1).Font.Bold = True
      .Rows(.Rows.Count).Font.Bold = True
      .Cut Destination:=Cells(5, 1)
      Columns("A:A").EntireColumn.AutoFit
      ActiveWindow.DisplayGridlines = False
      Columns("B:B").EntireColumn.AutoFit
      Range("C6").Select
      Range(Selection, Selection.End(xlDown)).Select
      Range(Selection, Selection.End(xlDown)).Select
      Selection.NumberFormat = "#,##0.00 $"
      Rows("4:4").Select
      Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End With
  End With
 
End Sub
 
Private Function WorksheetExists(Name As String, Optional ByVal Workbook As Excel.Workbook) As Boolean
  If Workbook Is Nothing Then Set Workbook = ActiveWorkbook
  On Error Resume Next
  WorksheetExists = Not (Workbook.Worksheets(Name) Is Nothing)
End Function

PS: In der GAForm kann es zu Fehlern kommen (bedingt durch den Einsatz von SpecialCells).


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
22.05.2014 10:05:48 HR
NotSolved
22.05.2014 15:30:55 Amicro2000
NotSolved
22.05.2014 19:19:51 Gast64552
NotSolved
Blau Excelliste auf mehrere Blätter verteilen
22.05.2014 19:25:42 Gast19909
NotSolved
22.05.2014 20:50:25 Gast60763
*****
Solved
23.05.2014 13:10:06 HR
NotSolved
23.05.2014 13:31:25 Gast24605
*****
Solved
23.05.2014 13:10:06 HR
NotSolved
23.05.2014 16:50:19 HR
NotSolved
23.05.2014 17:15:11 Gast66050
Solved