Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-07-2020, 03:06 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help to Highlight a cell that has less than 5 characters Windows 10 Help to Highlight a cell that has less than 5 characters Office 2019
Competent Performer
Help to Highlight a cell that has less than 5 characters
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default

I had concutted a script that worked for one specific word. But I would have loved to find both or more specific words with this script.

Code:
Sub Find_5_Letters_and_less_in_cell()
'Chr(13) = CR Carriage Return // Chr(7) = BEL or EndMarker
Dim tTbl As Table
Dim oCell As cell
Dim oRng As range
  
Application.ScreenUpdating = False

 Set tTbl = Selection.Tables(1)
  'For Each tTbl In ActiveDocument.range.Tables
   For Each oCell In tTbl.range.Cells
    'If oCell.range.Text = "Inc." + Chr(13) + Chr(7) Then
     If oCell.range.Text = "Ltd." + Chr(13) + Chr(7) Then
         oCell.range.HighlightColorIndex = wdYellow
     End If
  Next oCell
'Next
  Application.ScreenUpdating = True
   Application.ScreenRefresh
  DoEvents
  
lbl_Exit:
  Set tTbl = Nothing
  Set oRng = Nothing
  Exit Sub
  
  On Error GoTo 0
  
End Sub
Do you think it's doable? I had tried to put a coma in between the two words, but I got an error message.

The reason I ask, is because when I have a list of companies name with Ltd. and Inc., 10% of the time, I find it on a separate row alone in a cell. So when I have a long table, over 5K rows, scrolling is challengind. So I'm finding a difficult time, looking for these specific short words. And there could be more.



Cendrinne

Last edited by Cendrinne; 11-07-2020 at 09:11 AM. Reason: removed a line not necessary
Reply With Quote
Reply

Tags
highlight cells, less than 5 characters



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to Highlight a cell that has less than 5 characters Highlight only the characters ER when it occurs in SEVERE. norgro Word VBA 3 02-18-2013 05:14 PM
Help to Highlight a cell that has less than 5 characters How to highlight the row based on cell value? Learner7 Excel 1 12-11-2011 02:28 AM
Help to Highlight a cell that has less than 5 characters Highlight the first X number of characters 14spar15 Word 1 11-13-2011 11:17 PM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM
highlight cell after checkbox flatk Word 0 01-25-2007 12:32 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft