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
22.05.2014 19:25:42 Gast19909
NotSolved
Rot Komplett mir überarbeiteter GAForm
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:
Gast60763
Datum:
22.05.2014 20:50:25
Views:
2351
Rating: Antwort:
 Nein
Thema:
Komplett mir überarbeiteter GAForm
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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
    
  With ActiveSheet.UsedRange.CurrentRegion
     
    If .Columns.Count < 4 Then
      Call MsgBox("Keine Daten vorhanden.", vbExclamation)
      GoTo SafeExit
    End If
     
    If .Cells(2, 4).Value = WorksheetFunction.Average(.Columns(4)) Then
      Call MsgBox("Falsches Blatt aktiv.", vbExclamation)
      GoTo SafeExit
    End If
     
    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
       
      Call GAForm(wksDst)
       
      i = j + 1
    Loop
      
    Call .Worksheet.Activate
      
  End With
    
  Call MsgBox("Vorgang erfolgreich abschlossen.", _
              vbInformation, _
              "Erfolg")
    
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(Worksheet As Excel.Worksheet)
   
  Dim rng As Excel.Range
  Set rng = Worksheet.UsedRange.CurrentRegion
   
  If rng.Rows.Count = 1 _
    Then Exit Sub
   
  If Not ActiveSheet Is Worksheet _
    Then Worksheet.Activate
   
  'Datenbereich inkl. neue Summe-Zeile
  With rng.Resize(rng.Rows.Count + 1)
     
    'Kopfzeile
    With rng.Rows(1)
      Call .Clear
      .Font.Bold = True
      .Resize(ColumnSize:=3).Value = Array("Datum", "Code", "Wert")
    End With
     
    'neue Summe-Zeile
    With .Rows(.Rows.Count)
      .Font.Bold = True
      .Cells(1).Value = "Summe"
      .Cells(3).NumberFormat = "#,##0.00 $"
      .Cells(3).Formula = "=SUM(R[-1]C:R[-" & rng.Rows.Count - 1 & "]C)"
    End With
     
    'Datum- und Wert-Spalte formatieren
    .Columns(1).NumberFormat = "dd.mm.yyyy hh:mm"
    .Columns(3).NumberFormat = "#,##0.00 $"
     
    Call .Columns(2).AutoFit
     
    'Rahmen setzen
    .Borders.LineStyle = XlLineStyle.xlContinuous
    .Borders.Weight = XlBorderWeight.xlThin
     
  End With
   
  ActiveWindow.DisplayGridlines = False
   
  Call rng.Resize(RowSize:=4).Insert(xlShiftDown)
  Call rng.Cells(1, 1).Select
   
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

 


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
22.05.2014 19:25:42 Gast19909
NotSolved
Rot Komplett mir überarbeiteter GAForm
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