maybe this works already, if I assigned the sheets correctly:
Option Explicit
Sub GetSAPInfo()
Dim aData1, aData2, aDataOut, Fuel, Registration
Dim lRow1 As Long, lRow2 As Long, i As Long, j As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim Date1 As Date, Date2 As Date
Date1 = DateValue("01/02/2012")
Date2 = DateValue("01/05/2012")
Set ws1 = Worksheets("Fuel 6050")
Set ws2 = Worksheets("Vehicles")
With ws1
lRow1 = ws1.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
aData1 = .Range(.Cells(2, 1), .Cells(lRow1, .UsedRange.Columns.Count)).Value2
End With
With ws2
lRow2 = .Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
aData2 = .Range(.Cells(2, 1), .Cells(lRow2, .UsedRange.Columns.Count)).Value2
End With
ReDim aDataOut(LBound(aData2, 1) To UBound(aData2, 1))
For i = LBound(aData2, 1) To UBound(aData2, 1)
Fuel = 0
For j = LBound(aData1, 1) To UBound(aData1, 1)
If aData1(j, 11) = aData1(i, 1) And _
aData1(j, 7) > Date1 And _
aData1(j, 7) < Date2 Then
Fuel = Fuel + aData1(j, 5)
End If
Next j
aDataOut(i) = Fuel
Next i
With ws2
.Range(.Cells(2, 2), .Cells(UBound(aDataOut) + 2, 2)).Value2 = Application.WorksheetFunction.Transpose(aDataOut)
End With
End Sub
Bookmarks