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
Rot Automatisierte MaxWenn Abfrage
09.01.2016 16:41:39 Gast75249
NotSolved
09.01.2016 16:57:20 Sdeluxe
NotSolved
09.01.2016 21:30:59 Gast79981
NotSolved
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:
Gast75249
Datum:
09.01.2016 16:41:39
Views:
1094
Rating: Antwort:
  Ja
Thema:
Automatisierte MaxWenn Abfrage

Lieber Sdeluxe,

also wirklich prickelnd informativ war auch deine letzte Antwort nicht.

Egal, eine einfache Testumgebung:

Datendatei(en) - Spalte C mit  x bis 5000+/-x Zahlenwerten

ditto  - Spalte B1 mit  1. Kriterium (hier eine Maximalvorgabe)

ditto  - Spalte B2 mit  1. Kriterium (hier eine Minimalvorgabe)

ditto  - Spalte B3 mit  2. Kriterium (hier eine Maximalvorgabe)

ditto  - Spalte B4 mit  2. Kriterium (hier eine Minimalvorgabe)

Aufgabe:

Liste alle Dateien und schreibe die Dateinamen in Spalte A untereinander

dazu die Ergebnisse der MAX Funktion der Zahlenwerte jeder Datei

- und zwar nur innerhalb der Bandbreite Kriterium 1 bzw. 2

 

jetzt kannste den Code in ein leeres Workbook packen, den Pfad und

die Dateimaske anpassen

 

Was sich wirklich abspielen soll?

Dazu müsste " Function TestModul2a()" angepasst werden!

 

ABER, sry - bei deinen Erläuterungen bleibt das für mich "Schleierfahndung"!

 

Option Explicit

Sub TestModul1()
' ACHTUNG Microsoft Scripting Runtime in VBA-Editor/Extras/Verweise einbinden
'
' - erstelle eine sortierte Liste
' hier Tabelle "Ergebnisse" - Spalte A
'
'****************************************************
' hier die Voreinstellungen - anpassen!
Const LW_START As String = "E:\Temp"   'Startlaufwerk
Const NM_MASKE As String = "ANONYM-??-??-????.xlsx"
'****************************************************
'
Dim oFSO As New FileSystemObject
Dim oFolder As Folder
Dim oFile As File
'
Dim Rng As Range
'
   On Error GoTo TestModul1_Error
   Application.ScreenUpdating = False
'
   With Sheets("Ergebnisse")
      .Activate
      .Cells.Clear
      Set Rng = Cells(1, 1)
      '
      Set oFolder = oFSO.GetFolder(LW_START)
      For Each oFile In oFolder.Files
         If oFile.Name Like NM_MASKE Then
            Rng.Value = LW_START & "\" & oFile.Name
            Set Rng = Rng.Offset(1)
         End If
      Next oFile
      Columns(1).AutoFit
'
   End With
'
   On Error GoTo 0
'
TestModul1_Error:
'------------------------------------------------------------------------------
Select Case Err.Number
   Case Is = 0:   'errorless
      'Liste abarbeiten
      Call TestModul2
   Case Is = 9:   'Table
      Sheets.Add After:=Worksheets(Sheets.Count)
      ActiveSheet.Name = "Ergebnisse"
      Resume
   Case Is = 76:  'FSO
      Call MsgBox("Voreinstellungen Pfad?", vbCritical, "Abbruch")
      '
   Case Else:     'display
      '
End Select
'------------------------------------------------------------------------------
'
Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
Application.ScreenUpdating = True
'
End Sub
'
'
Sub TestModul2()
'**********************************************************************************
' ACHTUNG
'**********************************************************************************
' ggf. können Einschränkungen am installierten Office den  OLEDB-Zugriff verhindern
' - hier getestet unter Excel Version 15.0 = Excel 2013
' - Verweise im VBA Editor beachten
' ggf. AccessDatabaseEngine passend zum Windows Betreibmichsystem
' http://www.microsoft.com/de-de/download/details.aspx?id=13255
'**********************************************************************************
'
' - Schleife über die Liste
' - Abfragestring standard
Const SEL_FROM As String = "SELECT * FROM "
' - Objektdeklaration
Dim oConn As Object
Dim oRS As Object
Dim sSQL As String
'
Dim Rng As Range
Dim arrResult() As Variant
Dim x As Long
'
   On Error GoTo TestModul2_Error
'
   With Sheets("Temp")
      .Activate
      Set Rng = Sheets("Ergebnisse").Cells(1, 1)
      '
      Do While Len(Trim(Rng.Value)) > 0
         '
         Set oConn = CreateObject("ADODB.Connection")
         Set oRS = CreateObject("ADODB.Recordset")
         With oConn
            .Provider = "Microsoft.ACE.OLEDB.12.0"
            .ConnectionString = "Data Source=" & Rng.Value & ";" & _
            "Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"""
            .Open
         End With
         'erster Tabellenname
         Set oRS = oConn.OpenSchema(20)
         sSQL = SEL_FROM & Chr(91) & oRS.Fields(2).Value & Chr(93)
         Set oRS = Nothing
         'die Daten
         Set oRS = CreateObject("ADODB.Recordset")
         oRS.Open sSQL, oConn, 3, 1, 1
         If Not oRS.EOF Then
            .Cells.Clear
            .Cells(1, 1).CopyFromRecordset oRS
         End If
         '
         'jetzt die Auswertung
         arrResult = TestModul2a
         For x = LBound(arrResult) To UBound(arrResult)
            Rng.Offset(, x).Value = arrResult(x)
         Next x
         Set Rng = Rng.Offset(1)
      Loop
   End With
'
   On Error GoTo 0
'
TestModul2_Error:
'------------------------------------------------------------------------------
Select Case Err.Number
  Case Is = 0: 'errorless
  Case Is = 9:   'Table
      Sheets.Add After:=Worksheets(Sheets.Count)
      ActiveSheet.Name = "Temp"
      Resume
  Case Else: 'display
      
End Select
'------------------------------------------------------------------------------
End Sub
'
'
Function TestModul2a() As Variant
' - im temporären Arbeitsblatt mit Code die gewünschten Matrixformeln einfügen
' - Ergebnisse in das Hauptarbeitsblatt übertragen
' - aktive Tabelle ist IMMER noch "Temp"
'
' Voreinstellungen (wegen nicht bekannter Anforderungen als einfaches Beispiel):
' Spalte B enthält Zahlenreihen
' Spalte A je einen Maximal/Minimalwert (A1/A2)
' Spalte A je einen Maximal/Minimalwert (A3/A4)
' Regelformel
Const RULE_01 = "=MAX(IF((R[-5000]C:R[-1]C<=R[-5000]C[-1])*(R[-5000]C:R[-1]C>=R[-4999]C[-1]),R[-5000]C:R[-1]C))"
Const RULE_02 = "=MAX(IF((R[-5000]C:R[-1]C<=R[-4998]C[-1])*(R[-5000]C:R[-1]C>=R[-4997]C[-1]),R[-5000]C:R[-1]C))"
'
' hier 2 Regeln, daher
Dim myArr(1 To 2)
'
Dim Rng As Range
Dim lngRows As Long
Dim strFormula As String
Dim strSwap As String
'
Application.Calculation = xlCalculationManual
'
   With Sheets("Temp")
      'Spaltenlänge B
      Set Rng = Range(.Cells(1, 2), .Cells(Rows.Count, 2).End(xlUp))
      lngRows = Rng.Cells.Count
      'Formel Zelle darunter
      Set Rng = Rng.Cells(Rng.Cells.Count).Offset(1)
      'Wertetausch absolut
      strFormula = Replace(RULE_01, "5000", Format(lngRows, "0"))
      'jetzt die Bezüge
      strFormula = Replace(strFormula, "4999", Format(lngRows - 1, "0"))
      Rng.FormulaArray = strFormula
      .Calculate
      myArr(1) = Rng.Value
      'ditto
      Rng.Clear
      strFormula = Replace(RULE_02, "5000", Format(lngRows, "0"))
      strFormula = Replace(strFormula, "4998", Format(lngRows - 2, "0"))
      strFormula = Replace(strFormula, "4997", Format(lngRows - 3, "0"))
      Rng.FormulaArray = strFormula
      myArr(2) = Rng.Value
      .Calculate
   End With
Application.Calculation = xlCalculationAutomatic
TestModul2a = myArr
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
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
Rot Automatisierte MaxWenn Abfrage
09.01.2016 16:41:39 Gast75249
NotSolved
09.01.2016 16:57:20 Sdeluxe
NotSolved
09.01.2016 21:30:59 Gast79981
NotSolved
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