Sub resource_pool_Check()
Dim lastrow As Long 'declares the variable that holds the value for the last row
Application.ScreenUpdating = False 'Switches off screen updating
With Worksheets("MODTRACKER DATA").Range("AB2") 'selects the start range AB2 on worksheet MODTRACKER DATA
'[RP] no it doesn't select, there is no need to select it, selecting is very slow. _
It just sets a pointer your starting position - this is to avoid repeatedly referencing the cell
With .Offset(0, -12) 'checks for the last row of 12 columns to the left of the active cell
'[RP] again that is setting a pointer 12 cells left - we could actually roll the two With statements into a singleton, I prefer two
lastrow = .End(xlDown).Row
'[RP] Calculate the lastrow of your data in column P (i.e. 12 columns left of AB), which is referenced in the previous two With statements
With .Resize(lastrow - .Row + 1) 'not sure what this does?
'[RP] Our previous With statemnents just referenced P2, but we want to work on all the data ows. We know where it ends, lastrow, _
so we set a reference to all of those rows (e.g. if lastrow is 27, our start cell is P2, we are resing our range by 27-2+1=26 rows, _
so we will affect all 26 cells at one
.FormulaR1C1 = "=INDEX('Total Hours Booked'!R2C12:R2000C12,MATCH(RC[3],'Total Hours Booked'!R2C1:R2000C1,0))" 'enters the formula into which cell? AB2? what does Match(RC[3] mean?
'[RP] No into P2:P<lastrow-row+1> _
RC[3] is looking at the current row 3 cells right. We could have used A1 notation of "=INDEX('Total Hours Booked'!L2:L2000,MATCH(S2,'Total Hours Booked'!A2:A2000,0)) _
I just prefer the flexibility of R1C1 notation
.Value = .Value
'[RP] then we effectively do a copy>paste values
End With
End With
End With
MsgBox ("All Complete")
Application.ScreenUpdating = True
End Sub