View Single Post
 
Old 02-20-2020, 10:04 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Jennifer Murphy View Post
My only reluctance is that means the code to read the data is in the macro in two places, which always opens up the possibility of them not being identical.
But you still need to initialise it somehow. And, of course, the whole point of the comparison is to change the highlight when they cease to be identical. Rather more complicated code could be used to do that within the loop, but the code would then run more slowly overall, which brings us to:
Quote:
Originally Posted by Jennifer Murphy View Post
The other solution that I have used is to check inside the loop if it's the first iteration, but that puts code inside the loop that is unnecessary after the first iteration, which I also don't like.
Nor do I.
Quote:
Originally Posted by Jennifer Murphy View Post
What if I change the datatype of the variable to Variant? Is there a value, like Null, that I can initialize it to that can never be a match for anything that could ever be in a Word table?
I can't see the point of that - one could just as easily initialise it as:
StrTitle = ""
(or not even bother initialising it), but then the shading would necessarily start at the second data row (undesirable), though the code could be modified to make it start at the first data row.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote