Because I'm a big noob at VBA I can't seem to get this problem solved. I have the following problem:
I have an "Import" sheet where I import data. On that sheet I have 3 cells that change value all the time, C3,C4 and C5.
When these cells match with the cells from another table on another sheet I want to manipulate the value from a different column within the same table.
On an image it will look something like this:
When Column A matches with Apples, and Column B matches with Oranges, and Column C matches with Peaches then I want to do something to the number on the same row of column D.
I wrote the following code but it isn't working and just returning all the numbers from column D. I would I don't know what's going wrong.
I hope someone here could help me out.
Dim c1 As Range
Dim c2 As Range
Dim c3 As Range
Dim r1 As Range
Dim r2 As Range
Dim r3 As Range
Dim a1 As Range
Dim a2 As Range
Dim a3 As Range
Set r1 = Sheets("Specificaties").Range("H" & Rows.Count).End(xlUp)
Set r2 = Sheets("Specificaties").Range("I" & Rows.Count).End(xlUp)
Set r3 = Sheets("Specificaties").Range("J" & Rows.Count).End(xlUp)
Sleutel = Sheets("Specificaties").Range("M" & Rows.Count).End(xlUp).Row
Set a1 = Sheets("Import").Range("C3")
Set a2 = Sheets("Import").Range("C4")
Set a3 = Sheets("Import").Range("C5")
For Each c1 In r1
For Each c2 In r2
For Each c3 In r3
If c3.Value = a3.Value And _
c2.Value = a2.Value And _
c1.Value = a1.Value Then
For i = Sleutel To 3 Step -1
MsgBox Cells(i, 13).Value
Next
Else
MsgBox "Negative result"
End If
Next
Next
Next
End Sub
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…