98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » SUMIFS
SUMIFS
Resolved · Urgent Priority · Version 2007
Gerhardt has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course
SUMIFS
Hi
I am trying to do a SUMIFS in VBA. The below code works just perfect if I hardcode the arguments -
Sub Ageingformulas2()
Dim Customer As Range
Dim Bucket As Range
Dim Amount_GBP As Range
Set Customer = Sheets("K135512002").Range("G:G")
Set Bucket = Sheets("K135512002").Range("K:K")
Set Amount_GBP = Sheets("K135512002").Range("I:I")
With Sheets("K135512002")
Sheets("Mapping Table").Range("B13").Value = Application.WorksheetFunction.SumIfs(Amount_GBP, Customer, UK_BKKOREA, Bucket, 0-90 days)
End With
End Sub
When I change the code UK_BKKOREA to the value of Cell A13 and 0-90 days to Cell B12 it gives me a zero value.
The values in A13 will always change, so I do need this argument to look up the value in A13.
Below is an example of the code that returns a zero value
Sheets("Mapping Table").Range("B13").Value = Application.WorksheetFunction.SumIfs(Amount_GBP, Customer, A13, Bucket, B12)
So effectively I want the formula to work on whatever the value is of Cell A13 and not a hardcode value.
Can you PLEASE help????
RE: SUMIFS
Hi Gerhardt
Thanks for getting in touch, good to hear from you.
When you specify the values inside a WorksheetFunction from within VBA, you still need to put it in VBA-style terminology.
Therefore where you've specified A12, you should instead write it as Range("A12").
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Fri 31 May 2013: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Display Formulas Instead of Results in Excel 2010By pressing Ctrl ~ once, Excel will display formulas rather than the results of the formulas. Press it again, and the results will appear again. |