I'm trying to enter a SUMIF formula into my VBA but the range of cells may change depending on the 'Lastrow' on another tab. I'm able to get the Lastrow no problem but the problem is trying to enter into my SUMIF formula. 'Lastrow' value should replace cells Q156 & H156. Hope this makes sense. Any suggestions welcome.
See below:
Sub UpdateReconData()
Dim Lastrow6 As Integer
'gets last Row on Formatting Spreadsheet
Sheets("Formatting").Select
Lastrow6 = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row
Sheets("Recon").Select
Range("B2").Select
ActiveCell.Value = _
"=SUMIF(Formatting!$Q$2:$Q$156(Recon!$A2&Recon!B$1),Formatting!$H$2:$H$156)"
End Sub
#REF!
error unless you add in a comma between the criteria_range and the criteria_value. – user4039065