Hi
This code loops from the last row in the third column and looks for value = 91 and when it finds the value =91 it checks the fourth column for value = "Tomt" then it selects the cell in column 4 and extis the loop.
For x = lr To 1 Step -1
If db.Cells(x, 3) = 91 And db.Cells(x, 5) = "Tomt" Then
db.Cells(x, 4).Select
Exit Sub
End If
Next x
What i want to do know i is from the selected cell "previous loop" start to loop from selected cell to lastrow and sum every value in column 4 if the value 91 is true in column 3.
This is what i got so far:
For i = 1 To lr
If db.Cells(x, 3) = 91 Then db.Cells(x, 4). ???
End If
Next i
This is the whole code:
Sub tomt_senast_tid()
Dim db As Worksheet
Set db = ThisWorkbook.Sheets("db")
lr = db.Cells(Rows.Count, 1).End(xlUp).Row
For x = lr To 1 Step -1
If db.Cells(x, 3) = 91 And db.Cells(x, 5) = "Tomt" Then
db.Cells(x, 4).Select
Exit Sub
End If
Next x
For i = 1 To lr
If db.Cells(x, 3) = 91 Then db.Cells(x, 4). ???
End If
Next i
End Sub
Best regards
Petter
Bookmarks