this is my first time posting to the forum. i have been a novice programmer mainly for Excel VBA. usually simple codes to improve efficiency or accuracy of the information translated.
Currently i am faced with a project where there has been an error with my SumIFS formula.
The Database sheet is a sheet with the bulk load of information.the objective of the sumifs is to sum each week to the corresponding name and id.
the Database is linked with MS Access as well so that it remains dynamic with every update.
here are some fields in the Database which is crucial to the SUMIFS
ID - Column B Name - Column C Work - Column D Period - Column F
xx is the cell row where the formula is to be input. LR is the last row (this is where the period is placed as well on the main sheet)
i would need to drag this formula across the sheet to the current week. therefore im looking at autofill properties as well. which explains my attempt to lock them by the rows
Below is the code in concern.
With Sheets(CurrSheet).Range(UppLimit, BtmLimit) _
Set C = .Find("Actual", LookIn:=xlValues)
If Not C Is Nothing Then
firstAddress = C.Address
Do
xx = C.Offset(0, 2).Row
MsgBox xx
C.Offset(0, 2).Activate
activecell.formula= "SUMIFS(Database!$C:$C,Database!$F:$F,'2'!Range(LR,i),Database!$B:$B,'2'!Range(xx,1),Database!$C:$C,'2'!Range(xx,3),Database!$D:$D,'2'!Range($C$1)""
i = i + 1
Set C = .FindNext(C)
If C Is Nothing Then
GoTo DoneFinding
End If
Loop While Not C Is Nothing And C.Address <> firstAddress
End If
DoneFinding:
End With
Assuming your actual formula works correctly, this should work:
activecell.formula = "=SUMIFS(Database!$C:$C,Database!$F:$F,2!" & Cells(LR, i).Address & ",Database!$B:$B,2!" & Cells(xx, 1).Address & ",Database!$C:$C,2!" & Cells(xx, 3).Address & ",Database!$D:$D,2!" & Cells(1, 3).Address & ")"