Hi I am trying to convert formulas to vba code but I am facing an error in the next row I do not know how I can correct it
VBA Code:
Sub Macro3()
Dim lr As Long
Dim sh As Worksheet: Set sh = Sheets("Source")
Dim dest As Worksheet: Set dest = Sheets("Dest")
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
ws1 = sh.Name: WS2 = dest.Name
Set a = sh.Range("A2:A" & lr): Set b = sh.Range("B2:B" & lr)
Set c = sh.Range("C2:C" & lr): Set d = sh.Range("D2:D" & lr)
With dest.Range("b2:b" & Range("a" & Rows.Count).End(3).Row)
.Formula = "=IFERROR(INDEX('" & ws1 & "'!" & c.Address & "," & "MATCH(""=""&$E$1,'" & ws1 & "'!" & a.Address & ",""=""&$a$2,'" & ws1 & "'!" & b.Address
'.Formula = =IFERROR(INDEX(Source!$C$2:C$100; MATCH(1;($E$1=Source!A$2:A$100)*(A2=Source!B$2:B$100); 0));"")
With dest.Range("c2:c" & Range("a" & Rows.Count).End(3).Row)
.Formula = "=SUMIFS('" & ws1 & "'!" & d.Address & ",'" & ws1 & "'!" & a.Address & ",""=""&$E$1,'" & ws1 & "'!" & c.Address & ",""=""&$B2,'" & ws1 & "'!" & b.Address & ",A2)"
' Formula = "=SUMIFS('Source'!$D$2:D$100,'Source'!$A$2:A$100,$E$1,'Source'!$C$2:C$100,b2,'Source'!$B$2:B$100,a2)"
' .Value = .Value
' .Value = .Value
End With
End With
End Sub