Thema Datum  Von Nutzer Rating
Antwort
08.01.2016 13:04:22 Sdeluxe
NotSolved
08.01.2016 15:44:12 Gast443
NotSolved
08.01.2016 16:09:19 Sdeluxe
NotSolved
08.01.2016 18:01:31 Gast3271
NotSolved
09.01.2016 13:07:47 Gast42563
NotSolved
09.01.2016 16:03:32 Gast91282
NotSolved
09.01.2016 16:41:39 Gast75249
NotSolved
09.01.2016 16:57:20 Sdeluxe
NotSolved
09.01.2016 21:30:59 Gast79981
NotSolved
Blau Automatisierte MaxWenn Abfrage
09.01.2016 21:36:32 Gast77652
NotSolved
09.01.2016 23:59:31 Gast59495
NotSolved
10.01.2016 00:21:11 Sdeluxe
NotSolved
10.01.2016 12:16:55 sdeluxe
NotSolved
10.01.2016 12:16:57 sdeluxe
NotSolved
10.01.2016 12:16:57 sdeluxe
NotSolved
10.01.2016 12:16:58 sdeluxe
NotSolved
10.01.2016 13:48:56 Gast97395
NotSolved
10.01.2016 13:58:35 kleiner Tipp
NotSolved
10.01.2016 14:09:40 Sdeluxe
NotSolved
10.01.2016 14:41:17 Sdeluxe
NotSolved
10.01.2016 21:32:16 Gast81095
NotSolved
11.01.2016 16:26:17 Sdeluxe
NotSolved
11.01.2016 16:37:56 Gast83574
NotSolved
11.01.2016 16:48:47 Gast20373
NotSolved
11.01.2016 16:50:37 Sdeluxe
NotSolved
11.01.2016 17:17:30 Gast40485
NotSolved
11.01.2016 18:08:31 Sdeluxe
NotSolved
11.01.2016 18:17:07 Sdeluxe
NotSolved
11.01.2016 18:28:37 Gast53356
NotSolved
11.01.2016 22:44:18 Gast44726
NotSolved
11.01.2016 23:17:19 Gast33169
NotSolved
11.01.2016 23:26:34 Gast39029
NotSolved
12.01.2016 11:01:44 Gast31958
NotSolved
12.01.2016 12:56:43 Gast21654
NotSolved
12.01.2016 18:01:34 Gast86451
NotSolved
12.01.2016 18:18:48 Gast18345
NotSolved
12.01.2016 19:57:18 Sdeluxe
NotSolved
12.01.2016 20:48:19 Gast97233
NotSolved
12.01.2016 21:50:57 Sdeluxe
Solved
19.02.2016 20:15:24 Sdeluxe
NotSolved
20.02.2016 11:24:42 Gast75241
NotSolved
21.02.2016 11:48:52 Sdeluxe
NotSolved
21.02.2016 14:16:16 Gast72537
NotSolved
21.02.2016 15:05:46 Sdeluxe
NotSolved
21.02.2016 22:41:58 Gast37876
NotSolved
21.02.2016 22:52:55 Sdeluxe
NotSolved
22.02.2016 10:36:34 Gast23131
NotSolved
22.02.2016 13:18:50 Gast3434
NotSolved
22.02.2016 16:49:27 Gast24842
NotSolved
02.03.2016 18:09:25 Sdeluxe
NotSolved
02.03.2016 18:39:46 Gast72027
NotSolved
12.01.2016 20:48:21 Gast85010
NotSolved
11.01.2016 22:43:00 Gast23139
NotSolved

Ansicht des Beitrags:
Von:
Gast77652
Datum:
09.01.2016 21:36:32
Views:
816
Rating: Antwort:
  Ja
Thema:
Automatisierte MaxWenn Abfrage

Achso hatte mich da vertan. Jetzt passt es für Excel 2007 (Dateiendungen) etc, und mein Pfad ist raus. Falls es andere als .xlsx Datein sind, dass in Zeile 35 und 39 anpassen. 

Gruß

 

Option Explicit

Sub berechnen()
Dim name As String
Dim name2 As String
Dim mitwe
Dim max
Dim min
Dim i As Long
Dim bedingungen
Dim pfad As String
Dim suche As String
Dim zeile As Long
Dim summe
Dim formel1
Dim formel2
Dim anzahl As Long

bedingungen = Array("", "NEG_HT", "NEG_NT", "POS_HT", "POS_NT")

pfad = "       "  'hier den Pfad eingeben
If Right(pfad, 1) = "\" Then pfad = Left(pfad, Len(pfad) - 1)

Application.ScreenUpdating = False
name = ThisWorkbook.name

Workbooks(name).Worksheets(1).Cells(1, 1) = "Dateiname"
For i = 1 To 4
    Workbooks(name).Worksheets(1).Cells(1, 2 + (i - 1) * 3) = "Max " & bedingungen(i)
    Workbooks(name).Worksheets(1).Cells(1, 3 + (i - 1) * 3) = "Min " & bedingungen(i)
    Workbooks(name).Worksheets(1).Cells(1, 4 + (i - 1) * 3) = "Mittwelwert " & bedingungen(i)
Next i

zeile = 2
suche = Dir(pfad & "\*.xlsx")   'suche nimmt den Dateinamen auf
  
Do Until suche = ""

        If Left(suche, 6) = "Anonym" And Right(suche, 9) = "2015.xlsx" Then  'könnte man noch ausbauen
         
            Workbooks.Open pfad & "\" & suche
            name2 = ActiveWorkbook.name
            For i = 1 To 4
                anzahl = Application.WorksheetFunction.CountIf(Workbooks(name2).Worksheets(1).Columns(2), bedingungen(i))
                summe = Application.WorksheetFunction.SumIf(Worksheets(1).Columns(2), bedingungen(i), Worksheets(1).Columns(3))
                mitwe = summe / anzahl
            'Spalte B Bedingungen, Spalte C Werte
                formel1 = "=MAX((B1:B5100=" & Chr(34) & bedingungen(i) & Chr(34) & ")*(C1:C5100))"
                formel2 = "=SVERWEIS(" & Chr(34) & bedingungen(i) & Chr(34) & ";B1:C5100;2;FALSCH)"
                Workbooks(name2).Worksheets(1).Cells(1, 4).FormulaArray = formel1
                max = Worksheets(1).Cells(1, 4).Value
                Workbooks(name2).Worksheets(1).Columns("B:C").Sort Key1:=Workbooks(name2).Worksheets(1).Range("B1"), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
                Workbooks(name2).Worksheets(1).Cells(1, 5).FormulaLocal = formel2
                min = Worksheets(1).Cells(1, 5).Value
                       
                Workbooks(name).Worksheets(1).Cells(zeile, 4 + (i - 1) * 3) = mitwe
                Workbooks(name).Worksheets(1).Cells(zeile, 3 + (i - 1) * 3) = min
                Workbooks(name).Worksheets(1).Cells(zeile, 2 + (i - 1) * 3) = max
            Next i
           
            Workbooks(name2).Close savechanges:=False
           
            Workbooks(name).Worksheets(1).Cells(zeile, 1) = suche
            zeile = zeile + 1
        End If
  
          
    suche = Dir()
Loop
Workbooks(name).Worksheets(1).Range("A:M").Columns.AutoFit
Workbooks(name).Worksheets(1).Range("A:M").HorizontalAlignment = xlCenter
Application.ScreenUpdating = 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
08.01.2016 13:04:22 Sdeluxe
NotSolved
08.01.2016 15:44:12 Gast443
NotSolved
08.01.2016 16:09:19 Sdeluxe
NotSolved
08.01.2016 18:01:31 Gast3271
NotSolved
09.01.2016 13:07:47 Gast42563
NotSolved
09.01.2016 16:03:32 Gast91282
NotSolved
09.01.2016 16:41:39 Gast75249
NotSolved
09.01.2016 16:57:20 Sdeluxe
NotSolved
09.01.2016 21:30:59 Gast79981
NotSolved
Blau Automatisierte MaxWenn Abfrage
09.01.2016 21:36:32 Gast77652
NotSolved
09.01.2016 23:59:31 Gast59495
NotSolved
10.01.2016 00:21:11 Sdeluxe
NotSolved
10.01.2016 12:16:55 sdeluxe
NotSolved
10.01.2016 12:16:57 sdeluxe
NotSolved
10.01.2016 12:16:57 sdeluxe
NotSolved
10.01.2016 12:16:58 sdeluxe
NotSolved
10.01.2016 13:48:56 Gast97395
NotSolved
10.01.2016 13:58:35 kleiner Tipp
NotSolved
10.01.2016 14:09:40 Sdeluxe
NotSolved
10.01.2016 14:41:17 Sdeluxe
NotSolved
10.01.2016 21:32:16 Gast81095
NotSolved
11.01.2016 16:26:17 Sdeluxe
NotSolved
11.01.2016 16:37:56 Gast83574
NotSolved
11.01.2016 16:48:47 Gast20373
NotSolved
11.01.2016 16:50:37 Sdeluxe
NotSolved
11.01.2016 17:17:30 Gast40485
NotSolved
11.01.2016 18:08:31 Sdeluxe
NotSolved
11.01.2016 18:17:07 Sdeluxe
NotSolved
11.01.2016 18:28:37 Gast53356
NotSolved
11.01.2016 22:44:18 Gast44726
NotSolved
11.01.2016 23:17:19 Gast33169
NotSolved
11.01.2016 23:26:34 Gast39029
NotSolved
12.01.2016 11:01:44 Gast31958
NotSolved
12.01.2016 12:56:43 Gast21654
NotSolved
12.01.2016 18:01:34 Gast86451
NotSolved
12.01.2016 18:18:48 Gast18345
NotSolved
12.01.2016 19:57:18 Sdeluxe
NotSolved
12.01.2016 20:48:19 Gast97233
NotSolved
12.01.2016 21:50:57 Sdeluxe
Solved
19.02.2016 20:15:24 Sdeluxe
NotSolved
20.02.2016 11:24:42 Gast75241
NotSolved
21.02.2016 11:48:52 Sdeluxe
NotSolved
21.02.2016 14:16:16 Gast72537
NotSolved
21.02.2016 15:05:46 Sdeluxe
NotSolved
21.02.2016 22:41:58 Gast37876
NotSolved
21.02.2016 22:52:55 Sdeluxe
NotSolved
22.02.2016 10:36:34 Gast23131
NotSolved
22.02.2016 13:18:50 Gast3434
NotSolved
22.02.2016 16:49:27 Gast24842
NotSolved
02.03.2016 18:09:25 Sdeluxe
NotSolved
02.03.2016 18:39:46 Gast72027
NotSolved
12.01.2016 20:48:21 Gast85010
NotSolved
11.01.2016 22:43:00 Gast23139
NotSolved