Bold deletion

  • Thread starter Thread starter Yarroll
  • Start date Start date
Y

Yarroll

Hi,


I run a macro which checks if specific cells' font is bold. If it isn't,
then the whole row gets deleted. The lines in question read:

For k = howm To 2 Step -1 '(howm =
ActiveCell.SpecialCells(xlLastCell).Row )
If Cells(k, 12).Font.Bold = False Then
Rows(k).Delete
End If
Next

Macro works fine. But it operates on large number of workbooks, and a large
portion of these workbooks frequently have nothing whatsoever in bold (ie.,
everything, except header, gets deleted). My question: is it possible to
formulate a condition whereby the macro:
- first checks if a workbook has anything in bold,
- if there is, ( at least one Cells(k, 12).Font.Bold = True ) then the macro
proceeds as before, checks each and every row
- if nothing is in bold then everything is deleted right away.

I'm not sure if I dont beat around the bush here, namely, how can a macro
check if there is anything in bold in the workbook without going through
each and every one of cells? Still it seems like a waste of resources to
look at every Cells(k, 12) if a workbook always has nothing but Font.Bold =
False.

Thanks. Best regards
Yarroll
 
AFAIK you still must look at each cell to check for font condition so doing
that first wouldn't help much.
 
Hi Yarroll,

You can test to see whether no bold attributes have been set by using,

Activesheet.range("L2:L" & howm ).font.bold

which returns False if no cells are bold, True is all are bold cells and
Null if mixed bold/nobold cells.

Cheers
Andy
 
Andy Pope said:
Hi Yarroll,

You can test to see whether no bold attributes have been set by using,

Activesheet.range("L2:L" & howm ).font.bold

which returns False if no cells are bold, True is all are bold cells and
Null if mixed bold/nobold cells.

Cheers
Andy
Wow Andy, thanks.
I can certainly use the tip.

Best regards,
Yarroll
 

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

Back
Top