Solved

VBA Excel sumif how to inclued a not equal criteria

Posted on 2010-09-02
9
1,028 Views
Last Modified: 2012-05-10
I'm running some VBA code that passes to a sumif formula a string criteria I want that string criteria to be a not equal to stsement please see below, at the moment it adds everyting rather than excluding the search criteria

searchview= "<>CVN"

.SumIf(grnlable, SearchView, Range("tblCalc[Renewal_Premium]"))
0
Comment
Question by:Thrawn3000
  • 3
  • 3
9 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33592880
Is CVN the text "CVN"?
Try this

searchview= "<>""CVN"""
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33592892
You can ignore the previous comment.
Now that I have had a chance to test it, this works fine for me (Excel 2010)

searchview = "<>CVN"
MsgBox WorksheetFunction.SumIf(Range("A1:A10"), searchview, Range("B1:B10"))

Is the text CVN exactly or does it have extra spaces after?
0
 

Author Comment

by:Thrawn3000
ID: 33592904
Cyberkiwi
there are no extra spaces it is exactly CVN
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 45

Expert Comment

by:aikimark
ID: 33592907
searchview = "<>'CVN'"
0
 

Author Comment

by:Thrawn3000
ID: 33592939
No luck with that
0
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33593405
I think the key was to re-evaluate whether the text was in fact "CVN" exactly.
I was also of the mind like aikimark that quotes were required, but not so from VBA/worksheetfunction.
0
 

Author Closing Comment

by:Thrawn3000
ID: 33614252
The syntax this solution perscribed is correct.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now