Live-Forum - Die aktuellen Beiträge
Datum
Titel
29.03.2024 13:14:12
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1480to1484
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

INDEX Aggregat Funktion in VBA

INDEX Aggregat Funktion in VBA
18.03.2016 12:32:48
baschti007
Hallo liebe Forum User
ich habe bis jetzt immer mit der Formel
=WENNFEHLER(INDEX($J:$P;AGGREGAT(15;6;ZEILE(Tabelle2[ID])/(Tabelle2[ID]=$A13)/(Tabelle2[Zählen]=-1); ZÄHLENWENN($B$12:B$12;B$12)); VERGLEICH(B$12;$J$29:$XFD$29;)); "")
gearbeitet die mir Werner ( nochmals besten Dank) bereit gestellt hat nur wird die Excel Datei ziemlich langsam bei hunderten von gefüllten Zellen.
Und ich habe mir gedacht ob so etwas nicht in VBA umsetzbar ist?
Werte gibt es von 1 bis 12
und ID´s bis jetzt um die 4000 aber werden mehr.
Hier mein erster Versuch:
https://www.herber.de/bbs/user/104445.xlsm
Vielen Dank euch allen und eine schönes Wochenende
Gruß Basti

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: INDEX Aggregat Funktion in VBA
18.03.2016 13:28:53
ChrisL
Hi Basti
Die farbige Ausgangstabelle habe ich in Tabelle2!A1:G25 kopiert. Ergebnis wie gehabt auf Tabelle1.
Sub t()
Dim WS1 As Worksheet, WS2 As Worksheet
Dim iZeile As Long, iSpalte As Integer
Dim iiZeile As Long, iiSpalte As Integer
Set WS1 = Worksheets("Tabelle1")
Set WS2 = Worksheets("Tabelle2")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
WS1.Range("B2:U7").ClearContents
For iZeile = 2 To WS2.Range("A65536").End(xlUp).Row
If WS2.Cells(iZeile, 2) = -1 Then
iiZeile = Application.Match(WS2.Cells(iZeile, 1), WS1.Columns(1), 0)
For iSpalte = 3 To WS2.Range("IV1").End(xlToLeft).Column
iiSpalte = Application.Match(WS2.Cells(1, iSpalte), WS1.Rows(1), 0)
Do Until WS1.Cells(iiZeile, iiSpalte) = ""
iiSpalte = iiSpalte + 1
Loop
If WS1.Cells(1, iiSpalte) = WS2.Cells(1, iSpalte) Then _
WS1.Cells(iiZeile, iiSpalte) = WS2.Cells(iZeile, iSpalte)
Next iSpalte
End If
Next iZeile
Application.Calculation = xlCalculationAutomatic
End Sub

cu
Chris

Anzeige
AW: INDEX Aggregat Funktion in VBA
18.03.2016 14:21:35
baschti007
Vielen Dank Chris das hat mir sehr geholfen =)
ein schönes Wochenende dir
Gruß Basti

iiZeile = Application.Match(…) läuft in einen …
19.03.2016 03:54:49
Luc:-?
…unbehandelten Fehler, Chris,
iiSpalte = Application.Match(…) ebenso, wenn WS2.Cells(iZeile, 1) bzw WS2.Cells(1, iSpalte) nicht in WS1.Rows(1) bzw WS1.Columns(1) gefunden wird, da iiZeile As Long und iiSpalte As Integer ist (warum hier nicht immer Long ?), aber von Application.Match dann ein Fehlerwert geliefert wird, der As Variant erfordern würde (natürlich nebst Abfrage danach). WorksheetFunction.Match dagegen würde hier ebenfalls einen abfangbaren Fehler erzeugen.
Gruß + schöWE, Luc :-?
Besser informiert mit …

Anzeige
AW: iiZeile = Application.Match(…) läuft in einen
21.03.2016 06:56:35
baschti007
Hallo Ihr.
Ich hoffe Ihr hattet ein schönes Wochenenden.
Ich habe zwar keine Ahnung was " Luc :-?" meint aber mir ist aufgefallen das ab und an eine Fehler kommt "unverträglicher typ" . Gibt es da noch eine andere Löschung um das zu beheben ?
Gruß Basti

AW: iiZeile = Application.Match(…) läuft in einen
21.03.2016 07:27:00
hary
Moin
Match kann auch einen Fehler(wenn nicht vorhanden) wiedergeben. Daher erfordert Match eine Varinatvariable.
Versuch's mal so.
Dim WS1 As Worksheet, WS2 As Worksheet
Dim iZeile As Long, iSpalte As Long
Dim iiZeile As Variant, iiSpalte As Variant '-- Variant da Fehler kommen kann
Set WS1 = Worksheets("Tabelle1")
Set WS2 = Worksheets("Tabelle2")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
WS1.Range("B2:U7").ClearContents
For iZeile = 2 To WS2.Range("A65536").End(xlUp).Row
If WS2.Cells(iZeile, 2) = -1 Then
iiZeile = Application.Match(WS2.Cells(iZeile, 1), WS1.Columns(1), 0)
If IsNumeric(iiZeile) Then '--Fehlerpruefung
For iSpalte = 3 To WS2.Range("IV1").End(xlToLeft).Column
iiSpalte = Application.Match(WS2.Cells(1, iSpalte), WS1.Rows(1), 0)
If IsNumeric(iiSpalte) Then '--Fehlerpruefung
Do Until WS1.Cells(iiZeile, iiSpalte) = ""
iiSpalte = iiSpalte + 1
Loop
If WS1.Cells(1, iiSpalte) = WS2.Cells(1, iSpalte) Then _
WS1.Cells(iiZeile, iiSpalte) = WS2.Cells(iZeile, iSpalte)
End If
Next iSpalte
End If
End If
Next iZeile
Application.Calculation = xlCalculationAutomatic

gruss hary

Anzeige
AW: iiZeile = Application.Match(…) läuft in einen
21.03.2016 10:29:23
baschti007
Hallo
Super Hary
vielen Dank =)
gibt es eine Möglichkeit den Such Bereich auf WS1 in Spalte A auf Zeile z.B von 2-22 zu begrenzen ?
Gruß Basti

AW: iiZeile = Application.Match(…) läuft in einen
21.03.2016 11:08:17
ChrisL
Hi Basti
Probier mal...
Sub WorksheetFunction()
Dim WS1 As Worksheet, WS2 As Worksheet
Dim iZeile As Long, iSpalte As Long
Dim iiZeile As Variant, iiSpalte As Variant '-- Variant da Fehler kommen kann
Dim ZeileMax As Long
ZeileMax = 22 ' hier Zeilen-Maximum angeben
Set WS1 = Worksheets("Tabelle1")
Set WS2 = Worksheets("Tabelle2")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
WS1.Range("B2:U" & ZeileMax).ClearContents
For iZeile = 2 To WS2.Range("A65536").End(xlUp).Row
If WS2.Cells(iZeile, 2) = -1 Then
iiZeile = Application.Match(WS2.Cells(iZeile, 1), WS1.Range("A2:A" & ZeileMax), 0)
If IsNumeric(iiZeile) Then '--Fehlerpruefung
For iSpalte = 3 To WS2.Range("IV1").End(xlToLeft).Column
iiSpalte = Application.Match(WS2.Cells(1, iSpalte), WS1.Rows(1), 0)
If IsNumeric(iiSpalte) Then '--Fehlerpruefung
Do Until WS1.Cells(iiZeile + 1, iiSpalte) = ""
iiSpalte = iiSpalte + 1
Loop
If WS1.Cells(1, iiSpalte) = WS2.Cells(1, iSpalte) Then _
WS1.Cells(iiZeile + 1, iiSpalte) = WS2.Cells(iZeile, iSpalte)
End If
Next iSpalte
End If
End If
Next iZeile
Application.Calculation = xlCalculationAutomatic
End Sub

cu
Chris
Anzeige

229 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige