Hello everyone,
First I have to tell that there are maybe mistakes in my English. English isn't my first language and is sometimes difficult for me.
I'm working on an Excel worksheet, and I have troubles with a vba for this sheet.
The mean of this code is that it looks for 2 different values in cell D6 and D8, if both cells found in one row in another sheet then it have to change some cells. If both cells not found in a row, then it have to do someting else.
I hope you understand this. I use now this code. It goes on the red row in the code. Here it is search for the cell D6. But it has to also search to the cell D8
I hope there is someone who can helps me with this problem.
Code
Private Sub CommandButton1_Click()
Dim i As Long
With Sheets("Tarieflijst")
[COLOR=#FF0000]Set klant = .Range("A:P").Find((Range("D6")), after:=Sheets("tarieflijst").Range("A2"), SearchOrder:=xlByRows, searchdirection:=xlPrevious)[/COLOR]
If Not klant Is Nothing Then
werkbij klant.Row
For i = 2 To 1048576
If .Cells(i, 2) = "" Then Exit For
Next i
BewerkKlant i
'msgbox
MsgBox ("Klant toegevoegd en bijgewerkt")
Else
'Nieuwe klant toevoegen
If MsgBox("Nieuwe klant toevoegen?", vbYesNo) = vbYes Then
For i = 2 To 300
If .Cells(i, 2) = "" Then Exit For
Next i
BewerkKlant i
'msgbox
MsgBox ("Klant toegevoegd")
End If
End If
End With
End Sub
Display More