SumIf in vba returns 0 value in userform

djemy1975

Board Regular
Joined
Jan 18, 2016
Messages
51
Dear firends,

I have a userform "frmSuivi" in which I want to display some calculations ,among them count and sumif

I have set up the functions for those calculations but the result is "0".I think the problem is related to numbers format in the sheet ,knowing that the data is entered via another userform.I could not figure out how to get this problem over .

Could someone help me to go through.

the code is put in userform initialize
Code:
Private Sub UserForm_Initialize()


sn = Sheets("BDD").Cells(1).CurrentRegion
    For j = 1 To UBound(sn, 2)
        ListView10.ColumnHeaders.Add , , sn(1, j), 90
    Next
    For j = 2 To UBound(sn)
        With ListView10.ListItems.Add(, , sn(j, 1))
           For jj = 2 To UBound(sn, 2)
                .ListSubItems.Add , , sn(j, jj)
           Next
        End With
    Next
    ListView10_Click
 'Sum of paid invoices
Dim rB As Range
Dim dResult As Variant
Set rB = Worksheets("BDD").Range("G2:G1000")


dResult = Application.WorksheetFunction.SumIfs(rB.Offset(0, 4), rB, "Paid")

TextBox7 = dResult

end sub
Thanks in advance,
 
Last edited by a moderator:

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
38,820
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
I think you'll need to adjust the code in the other form that populates the cells. I suspect your data range cells are actually text and not numbers.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,668
Messages
5,838,680
Members
430,563
Latest member
Raeyven

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
Top