Solved

VBA Excel sumif how to inclued a not equal criteria

Posted on 2010-09-02
9
1,091 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

739 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