Finding cells using a style

S

Simon Reid

Is there any way to find all the cells in a worksheet/workbook that use a
particular style? I can only think of looping over all cells but that will
be far too slow for the size of workbooks I have.

The problem I have is that I want to be able to change the number format on
all cells that have the Total style. The Total style though doesn't include
a number format currently, and instead will be either a number or percentage
depending on how the user has configured it. I need to update the decimal
places used in the cells, so was going to write a tool to look at all cells
with the Total style.
 
D

Dave Peterson

In newer versions of excel (xl2002+, I think), you can show the Find dialog and
include formatting for the search criteria.

In fact, if you're doing it manually, you can look within the workbook.

But if you're doing it by code, you'll have to loop through the sheets.

You can record a macro when specify the formatting parms to get the syntax
correct.

If you're using xl2k or earlier, you'll be stuck looping through the worksheets
and through the usedranges.
 
S

Simon Reid

Great, I am using Excel 2007, and am actually coding it in C# using VSTO, I
assume you can use the Range.Find method?
 

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