ist es möglich durch eine For-Schleife verschiedene Arrays zu durchsuchen?
bsp.
5 Arrays sind vorhanden.
For i = 1 to 5
dann in Array(i) nach bestimmtem wert Suchen.
Geht das überhaupt wenn ja wie?
Danke schon mal
ArrX = Array(arr1, arr2, arr3, arr4, arr5)
for i = 0 to 4
Suche dann in ArrX(i)
wenn du auf einzelne Werte des Schleifen Arrays zugreifen willst: ArrX(i)(1)
Next
Gruß DanielSub a()
Dim myArray() As Variant
Dim i As Integer, j As Integer
ReDim myArray(4, 4)
For i = 0 To 4
For j = 0 To 4
myArray(i, j) = "Dimension: " & i & "--- index: " & j
Next j
Next i
End Sub
Wenn du dann die Werte des Arrays anschaust, sieht das aufgelistet so aus:
Dimension: 0--- index: 0
Dimension: 0--- index: 1
Dimension: 0--- index: 2
Dimension: 0--- index: 3
Dimension: 0--- index: 4
Dimension: 1--- index: 0
Dimension: 1--- index: 1
Dimension: 1--- index: 2
Dimension: 1--- index: 3
Dimension: 1--- index: 4
Dimension: 2--- index: 0
Dimension: 2--- index: 1
Dimension: 2--- index: 2
Dimension: 2--- index: 3
Dimension: 2--- index: 4
Dimension: 3--- index: 0
Dimension: 3--- index: 1
Dimension: 3--- index: 2
Dimension: 3--- index: 3
Dimension: 3--- index: 4
Dimension: 4--- index: 0
Dimension: 4--- index: 1
Dimension: 4--- index: 2
Dimension: 4--- index: 3
Dimension: 4--- index: 4
Option Explicit
Private ws As Worksheet
Sub CheckValues()
Dim myList As New ArrayList
Dim cRow As Long, i As Long
Dim rng As Range, c
Set ws = ThisWorkbook.Sheets("wörter")
CreateList myList
Set ws = ThisWorkbook.Sheets("search")
With ws
cRow = .Cells(.Rows.Count, 1).End(xlUp).Row
Set rng = .Range(.Cells(1, 1), .Cells(cRow, 1))
For Each c In rng
For i = 0 To myList.Count - 1
If c = myList(i) Then
c.Offset(, 1) = 1
Exit For
End If
Next i
Next c
End With
End Sub
Private Sub CreateList(ByRef myList As ArrayList)
Dim i As Integer
With ws
For i = 1 To 43
myList.Add .Cells(i, 1)
Next i
End With
End Sub
Das ist nur ein Beispiel, der Code ist einfach schnell dahin geschrieben und über
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(i, 4).Value Like "*greifer*" Or Cells(i, 4).Value Like "*PNG*" Then
Cells(i, 6).Value = 15
End If
Für jede gruppe einen If-block schreiben
Next i