Word macro: how to apply highlight to *all* selected text
Thread poster: Samuel Murray

Samuel Murray  Identity Verified
Netherlands
Local time: 12:08
Member (2006)
English to Afrikaans
+ ...
SITE LOCALIZER
Dec 24, 2019

Hello everyone

I have a table in which I want to highlight certain cells. I'm using Ctrl+select to select the cells that I want to be highlighted. If I select cells and then use the normal "Highlight" button or function, it highlights all selected cells. But if I use the following macro, it highlights only the cells that I have selected last:

Sub highlight_with_shortcut()
Selection.Range.HighlightColorIndex = wdPink
End Sub

Just to be clear,
... See more
Hello everyone

I have a table in which I want to highlight certain cells. I'm using Ctrl+select to select the cells that I want to be highlighted. If I select cells and then use the normal "Highlight" button or function, it highlights all selected cells. But if I use the following macro, it highlights only the cells that I have selected last:

Sub highlight_with_shortcut()
Selection.Range.HighlightColorIndex = wdPink
End Sub

Just to be clear, the cells that I want to highlight are not next to each other, so I'm holding in Ctrl while selecting additional cells. The macro above then applies to only the cell(s) that I selected last, but I want the macro to apply to all selected cells.

How do I do that?
Thanks
Samuel
Collapse


 

Hans Lenting  Identity Verified
Netherlands
Member (2006)
German to Dutch
Neem er een loopje mee? Dec 24, 2019

Perhaps you have to insert a loop: for each cell in the range?

 

Rolf Keller
Germany
Local time: 12:08
English to German
Just a simple Loop Dec 24, 2019

Option Explicit

Sub highlight_with_shortcut()

Dim singleCell As Cell
Dim allSelectedCells As Cells

Set allSelectedCells = Selection.Cells

For Each singleCell In allSelectedCells
singleCell.Range.HighlightColorIndex = wdPink
Next singleCell

End Sub


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Word macro: how to apply highlight to *all* selected text

Advanced search






SDL Trados Studio 2019 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2019 has evolved to bring translators a brand new experience. Designed with user experience at its core, Studio 2019 transforms how new users get up and running, helps experienced users make the most of the powerful features.

More info »
WordFinder Unlimited
For clarity and excellence

WordFinder is the leading dictionary service that gives you the words you want anywhere, anytime. Access 260+ dictionaries from the world's leading dictionary publishers in virtually any device. Find the right word anywhere, anytime - online or offline.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search