If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Bold deletion
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 |
#3
|
|||
|
|||
Bold deletion
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 Yarroll wrote: 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 -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
#4
|
|||
|
|||
Bold deletion
"Andy Pope" ... 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 |
Thread Tools | |
Display Modes | |
|
|