Hey all,
I hope to apply a SumIF function to a range defined by a few variables (lastRow, lastCol ect.). I prefer the result left in the cells as just the number, but getting the result by applying a formula in the cell will work as well. I have tried a few things, but couldn't make it work, so I really hope someone can help me out. Please see attached file, as it shows better what I need done. Thanks a lot in advance for you effort!
To make it easier I took most of the code out, leaving this:
Sub makro1()
Dim i As Variant
Dim lastRow As Integer
Dim actCol As Integer
Dim actRow As Integer
Dim lastCol As Integer
'the variables are determined in the code I took out, but will vary from time to time changing according to the data.
lastCol = 11
lastRow = 10
actCol = 5
actRow = 6
i = 3
With Cells(lastRow + 3, actCol).Resize(lastRow - actRow, i)
.Formula = Application.WorksheetFunction.SumIf(Range("$E$6:$K$6"), Range("E$12") & "*", Range("$E7:$K7"))
End With
End Sub
Bookmarks