• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro that cycles through a workbook and returns the names of the sheets that meet certain criteria

KateA

New Member
I’ve currently making a workbook in which I have about eighty sheets, each relating to a specific customer, and two or three other sheets summary sheets which analyse the whole portfolio.

In one of these summary sheets I want to pose a few (kind of) questions that look like
1. The percentage of income generated by ________ that comes from _______ fees is _____%
2. …
3. A list of companies who’s exposure from ______(K5)__ is greater than___(M5)_____;
…….and that sort of thing, where into the cells that look like_____ I can type different criteria and so return different answers in the answer space.
I’m having trouble with the list part. I’ve no idea how to write macros and I think what is required here is a macro that cycles through every worksheet in the workbook.
Each worksheet is named after its company. The layout of all worksheets is the exact same. In the column D is the names of the sources of income and in column H is the amount of income generated by each source. Some, in fact most, cells in the H column are zero.
I want to write a macro that takes the words that I’ve typed into the cells K5 and M5 and searches each sheet in turn for these words, selects the number parallel to each word, compares the two numbers, and if figure A is bigger than B returns the name of the current worksheet into the column O in the summary worksheet where I want my list.
What I’m finding particularly difficult is thinking of how to get the first company that fits the criteria into the first cell of the column, and then even though there may not be another match for a number of sheets after that, the second company that fits the criteria into the second cell.
If it would help people get a clearer idea of what I want to happen I can post the macro that I've written so far, but I have a feeling it may actually impede the process of understanding, due to my nonexistant vba skills.
If anyone has a solution I’d really appreciate it! Thanks a million
Kate
 
Hi Kate,

Sounds like an interesting challenge. Could you post a trimmed down version (scramble/randomize sensitive data of course) of the workbook, perhaps showing what you are trying to achieve? I've got an idea on how to get the answer, but I want to make sure I'm on the same page as you before diving in.
 
Of course I can! Unfortunately all of the information is sensitive but here is a template of the sheet where each company's facts and figures appears. There is eighty or so of these sheets in the workbook. The columns this particular list is concerned with are the income columns, from rows 52 to 67. Hopefully this helps, if you need any more information just let me know.

Thanks a mill for your time
 

Attachments

  • Copy of SAMPLE CRSP.xlsx
    365.3 KB · Views: 3
Back
Top