Sumifs VBA #Value Error

xs4amit

New Member
Joined
May 21, 2018
Messages
34
Hi,

i am trying to do Sumifs using VBA, below is my Code:

Sub Mandays()
Application.ScreenUpdating = False


Dim Summ As Double
Dim WS1, WS2 As Worksheet
'Dim Arr1 As Variant
Dim Rng1, Rng2, Rng3, Rng4, Rng5 As Range
Dim tFilter1, tFilter2, tFilter3, tFilter5 As String
'Dim i As Long




Set WS1 = Sheets("Daily_Production_Stats")
Set WS2 = Sheets("Master_WDD")
'Arr1 = WS1.UsedRange.Value
Rng1 = WS2.Range("P2:P30000")
Rng2 = WS2.Range("F2:F30000")
Rng3 = WS2.Range("D2:D30000")
Rng4 = WS2.Range("J2:J30000")
tFilter1 = WS1.Range("C5")
tFilter2 = WS1.Range("D1")


With WS1
.Range("A5:A300").Clear


.Cells(5, 1).Value = .Application.WorksheetFunction.SumIfs(Rng1, Rng2, tFilter1, Rng4, tFilter2)


.Activate
End With


End Sub


I am getting #Value as a result whereas Manual Sumifs formula is returning accurate values. Am i missing something??
 
Yes, It produces the same result. But i wants to get it done using VBA code because data is huge.
Thanks Steve
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,393
Messages
6,124,680
Members
449,180
Latest member
kfhw720

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top