How to Create Function Sumifs by VBA-Excel - learnit

Home Top Ad

Post Top Ad

Tuesday, September 27, 2022

How to Create Function Sumifs by VBA-Excel

How to Create Function Sumifs by VBA-Excel

Code for Create Function Sumifs

Sub Button1_Click()
Dim item_name As String
Dim Customer_name As String
Dim total As Long
total = 0
item_name = Worksheets("Sheet1").Cells(2, 8).Value
Customer_name = Worksheets("Sheet1").Cells(2, 9).Value
lastrow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Sheet1").Cells(i, 2).Value = item_name And Worksheets("Sheet1").Cells(i, 2).Value = Customer_name Then
total = total + Worksheets("Sheet1").Cells(i, 4).Value
End If
Next
Worksheets("Sheet1").Cells(2, 10).Value = total
Worksheets("Sheet1").Cells(1, 1).Select
End Sub

Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad