![]() |
#1
|
||||
|
||||
![]()
I have a table of results for a collection of experiments. Each experiment has a title and may be run multiple times with different criteria. When I sort the table by the title, I like to highlight every other set of results with a light blue background. This helps be focus on the results for each experiment.
I did this manually once. But now I have added some new experiments that sort between existing experiments. Unless I redo the entire list, I will have two consecutive sets with the same highlighting (blue or none). I would like to write a macro to redo the highlighting every time I add a new experiment, but my skills with Word VBA is not good enough. Can someone give me the initial outline of a macro that will loop through each line (row) of a table, examine the title field, and change the highlighting whenever the title changes? Here's a rough outline of what I think the macro needs to do. The code in parens is what I don't know how to do. Code:
Sub TableHiLite() 'Not sure if it needs parameters Dim HiLite as boolean HiLite = True Dim Row as Integer Dim NumRows as Integer NumRows = (number of rows in the table) Dim TitleNext as String Dim TitlePrev as String For Row = 2 to NumRows TitleNext = (title text in this row) If TitleNext <> TitlePrev then HiLite = Not HiLite If HiLite then (set the highlight for this row to light blue) Else (set the highlight for this row to light none) Next Row End Sub PS: Ooops. I just realized that this should have gone into the VBA section. Maybe someone can move it. Sorry. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
bakerkr | Word VBA | 4 | 10-19-2017 02:23 PM |
![]() |
Benbon | Word VBA | 3 | 03-30-2017 02:31 PM |
![]() |
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
![]() |
bertietheblue | Word VBA | 9 | 07-01-2013 12:39 PM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |