Ok so i have been self teaching myself and so far i have written the code below, which is returning the individual values i want and putting them in the range "FirstTargetCell".
what i really want to do now is put one figure on the summary sheet in "C30" that sums all the figures or the FirstTargetCell, thats easy but i want to do it another way.
i dont want to use FirstTargetCell but rather within the code i have written, say i create "C" and C=0 to start with, at the end of the 1st loop of IF statements in the code i want "C" to equal the result that would have been placed in the first cell, then after the second loop of IF statements C=C+ (the next result)
Which at the end of all the loops C= Total days labour for heat and i want this value in "C30"
Updated spreadsheet attached.
Sub summary()
Dim FirstCell As Range
Dim FirstTargetCell As Range
Dim I As Integer
Dim TMR As Single
Set Myrange = Sheets("Team List").Range("C1:d500")
Set FirstCell = Sheets("heat").Range("A5")
Set FirstTargetCell = Sheets("Summary").Range("M6")
I = 0
TMR = Application.WorksheetFunction.VLookup(FirstCell, Myrange, 2, False)
Do
If FirstCell.Offset(I, 7).Value = "" Then
FirstTargetCell.Offset(I, 0).Value = ""
Else
If FirstCell.Offset(I, 3).Value = "AL" Then
FirstTargetCell.Offset(I, 0).Formula = TMR * 0 * FirstCell.Offset(I, 7)
Else
If FirstCell.Offset(I, 3).Value = "LS" Then
FirstTargetCell.Offset(I, 0).Formula = TMR * 0 * FirstCell.Offset(I, 7)
Else
If FirstCell.Offset(I, 3).Value = "SW" Then
FirstTargetCell.Offset(I, 0).Formula = TMR * 1.5 * FirstCell.Offset(I, 7)
Else
If FirstCell.Offset(I, 3).Value = "NL" Then
FirstTargetCell.Offset(I, 0).Formula = TMR * 1.5 * FirstCell.Offset(I, 7)
Else
FirstTargetCell.Offset(I, 0).Formula = TMR * FirstCell.Offset(I, 7)
End If
End If
End If
End If
End If
I = I + 1
Loop Until FirstCell.Offset(I, 0).Value = ""
End Sub
I have moved this from an early post as i think the description was confusing
http://www.excelforum.com/excel-prog...html?p=3037216
and it was also added on another forum by a workmate
http://www.mrexcel.com/forum/excel-q...ml#post3335621
Bookmarks