Excel 2003 - VBA - SUMIF

C

Craig Brandt

Here is a tough one:

I have a table with rows of information including an ID Code. The ID code is
made up of four characters, each meaning something distinct. I want to
create a flexible reporting system where the user can specify which of these
rows to include in the report. Up to here there have been no problems,
example;

Code IMDA specifies an account that is active, indicated by the "A". Most
accounts are Active but there is also the possibility for it to be Inactive,
in which case the Code would have been IMDI, for Inactive. To gather the Net
Worth of these accounts, I simply look for the distinct code.


SUMIF(A5:A1500,"IMDA",CW5:CW1500)

SUMIF(A5:A1500,"IMDI",CW5:CW1500)



Challenge:
I would like to have the ability to use wildcards (+) in the Code to
indicate that any character in that position should be considered a match.
The above code would produce a report that has two cells showing all Active
IMD accounts (IMDA), and all Inactive (IMDI).



I would like to offer the user the ability to insert the wildcard by
changing the code to be able to handle a Pseudo Code of IMD+ where the last
character is inconsequential to a match. In the real world, this "+" could
be in any position.



Does anyone have any suggestions on how to proceed?

Craig
 
R

Ron Rosenfeld

Here is a tough one:
I would like to offer the user the ability to insert the wildcard by
changing the code to be able to handle a Pseudo Code of IMD+ where the last
character is inconsequential to a match. In the real world, this "+" could
be in any position.



Does anyone have any suggestions on how to proceed?

Craig

The SUMIF text criteria uses the same wildcard tokens -- * or ? -- as does
other Excel functions that can use wild cards.

IMD? for a 4 character code starting with IMD and for which the 4th character
is irrelevant.

IMD* for any length code that starts with IMD
--ron
 
C

Craig Brandt

Ron:

It never ceases to amaze me. Some things that look impossible, turn out to
be really simple solutions.

Thanks again,
craig


 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top