Basically, i am trying to use sumif function in vba. Instead of using fixed rows and columns, i am trying to make everything dynamic. here is the code i wrote to accomplish the task but failed.
sh.Range("V" & StartRowData j).Value = Application.WorksheetFunction.SumIf _ (MettBeheer.Range("A1", "A" & LastRowMettBeheer), sh.Range("A" & StartRowData j).Value, MettBeheer.Range("K1", "K" & LastRowMettBeheer))
the first two parameter of the function are ok. this part of the code
Range("K1", "K" & LastRowMettBeheer) where i want to make it dynamic. instead of a fixed k range, it could be from a to end of the used columns in the sheet based on the criteria give from this code
sh.Range("A" & StartRowData j).Value
any suggestion or help is highly appreciated?