Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA Excel sumif how to inclued a not equal criteria

Posted on 2010-09-02
9
Medium Priority
?
1,221 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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 46

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

886 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