![]() |
Programmatically check cell formatting
I have exported a task list from Project. Column C contains task names.
Summary tasks are bold and actual (working) tasks are not. I would like to (until there isn't any more data in Column C) insert a row after each task that is not a summary task (ie, not bold). I found other examples of inserting rows, but I don't know how to check this specific cell/text formatting. Any help is greatly appreciated. -------------- Justin |
Programmatically check cell formatting
Try something like the following:
Dim RowNdx As Long Dim LastRow As Long LastRow = Cells(Rows.Count, "C").End(xlUp).Row For RowNdx = LastRow To 1 Step -1 If Cells(RowNdx, "C").Font.Bold = False Then Rows(RowNdx + 1).Insert End If Next RowNdx -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "WhyIsEverythingSoConfusing" wrote in message ... I have exported a task list from Project. Column C contains task names. Summary tasks are bold and actual (working) tasks are not. I would like to (until there isn't any more data in Column C) insert a row after each task that is not a summary task (ie, not bold). I found other examples of inserting rows, but I don't know how to check this specific cell/text formatting. Any help is greatly appreciated. -------------- Justin |
Programmatically check cell formatting
Works like a champ, thanks!
One little issue, though. All of my cells have borders. Rows inserted in the middle of the document maintain these borders. The last inserted row doesn't, however. Is there a quick way to ensure that this last row has the same formatting as the rest of the rows? -------------- Justin "Chip Pearson" wrote: Try something like the following: Dim RowNdx As Long Dim LastRow As Long LastRow = Cells(Rows.Count, "C").End(xlUp).Row For RowNdx = LastRow To 1 Step -1 If Cells(RowNdx, "C").Font.Bold = False Then Rows(RowNdx + 1).Insert End If Next RowNdx -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "WhyIsEverythingSoConfusing" wrote in message ... I have exported a task list from Project. Column C contains task names. Summary tasks are bold and actual (working) tasks are not. I would like to (until there isn't any more data in Column C) insert a row after each task that is not a summary task (ie, not bold). I found other examples of inserting rows, but I don't know how to check this specific cell/text formatting. Any help is greatly appreciated. -------------- Justin |
Programmatically check cell formatting
The borders are retained for all cells when I run the code.
-- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "WhyIsEverythingSoConfusing" wrote in message ... Works like a champ, thanks! One little issue, though. All of my cells have borders. Rows inserted in the middle of the document maintain these borders. The last inserted row doesn't, however. Is there a quick way to ensure that this last row has the same formatting as the rest of the rows? -------------- Justin "Chip Pearson" wrote: Try something like the following: Dim RowNdx As Long Dim LastRow As Long LastRow = Cells(Rows.Count, "C").End(xlUp).Row For RowNdx = LastRow To 1 Step -1 If Cells(RowNdx, "C").Font.Bold = False Then Rows(RowNdx + 1).Insert End If Next RowNdx -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "WhyIsEverythingSoConfusing" wrote in message ... I have exported a task list from Project. Column C contains task names. Summary tasks are bold and actual (working) tasks are not. I would like to (until there isn't any more data in Column C) insert a row after each task that is not a summary task (ie, not bold). I found other examples of inserting rows, but I don't know how to check this specific cell/text formatting. Any help is greatly appreciated. -------------- Justin |
All times are GMT +1. The time now is 06:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com