Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies. Only from Platform Scholar.
Public Sub CalculateYTDCustomerSalesAndMargins() Dim UniqueCustomers, Output, Claimbacks As Variant Dim i, c, j, k, z As Double UniqueCustomers = Range("UniqueCustomers") Claimbacks = Range("ClaimBacks") ReDim Output(1 To UBound(UniqueCustomers), 1 To 5) j = 0 'Sales variable k = 0 'Cost of sales variable z = 0 'Claim backs variable For c = 1 To UBound(UniqueCustomers) For i = 1 To UBound(Claimbacks) If UniqueCustomers(c, 2) = Claimbacks(i, 5) Then j = j + Claimbacks(i, 11) * Claimbacks(i, 10) k = k + Claimbacks(i, 12) * Claimbacks(i, 10) z = z + Claimbacks(i, 22) Output(c, 1) = j Output(c, 2) = k Output(c, 3) = 1 - k / j Output(c, 4) = z Output(c, 5) = 1 - (k - z) / j End If Next i j = 0 'Sales variable k = 0 'Cost of sales variable z = 0 'Claim backs variable Next c Range("E2", Range("I" & UBound(UniqueCustomers) + 1)) = Output End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.