Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to design report excel application in which different fields are relate each other in input excel sheet.In that input excel sheet fields description given below
One Supplier(Column) has many invoices(Column).An entries of suppliers are not serially(are present in different rows) and each invoice has different items entry.How to write sub routine for calculate total number of invoices of suppliers using excel vba??
Posted
Comments
CHill60 9-Jul-14 8:21am    
What have you tried? Your description of the data is not clear enough
Venkat Raghvan 9-Jul-14 9:42am    
I getting supplier and their invoice list in same excel sheet and one condition is that if supplier bought multiple item in one invoice, it set empty cell for that item.

Sub GetInvoices()

Dim i As Integer, j As Integer, cnt As Integer

Dim totalMatch As Integer
Dim Key As String, num As String
With Sheets(2)
lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
End With
'Run loop until last row

For i = 2 To lastRow
'Check for matched values of suppliers
num = WorksheetFunction.Match(Cells(i, 4), Range("D1:D" & lastRow), 0)

If i = num Then
cnt = cnt + 1
Cells(i, 11).value = cnt

End If
Next i
End Sub

1 solution

VB
iVal= Application.WorksheetFunction.CountIfs(Sheets(2).Range("I1:I10"),Sheets(2).Cells(i, 9), Sheets(2).Range("D1:D10"),"0")


iVal returns total number of '0' occurred with respect to column 'I' as input and column 'D' as reference value
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900