Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-16-2019, 05:03 AM
gmaxey gmaxey is offline Looking for a macro for word count in one specific column of table, only rows with white background Windows 10 Looking for a macro for word count in one specific column of table, only rows with white background Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngCount
Dim oCell As Cell
Dim oRng As Range
  For Each oCell In Selection.Tables(1).Range.Cells
    If oCell.Range.Information(wdEndOfRangeColumnNumber) = 2 Then 'or whatever column index you need
      If oCell.Shading.BackgroundPatternColor = wdColorAutomatic Then
        Set oRng = oCell.Range
        oRng.End = oRng.End - 1
        lngCount = lngCount + oRng.ComputeStatistics(wdStatisticWords)
      End If
    End If
  Next
  MsgBox lngCount
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for a macro for word count in one specific column of table, only rows with white background Macro to delete table rows based on the absence of a single specific keyword JellehFishh Word VBA 2 06-27-2019 08:23 AM
Looking for a macro for word count in one specific column of table, only rows with white background Macro delete table rows if cell in first column = $ Btop Word VBA 7 02-13-2018 05:36 PM
Looking for a macro for word count in one specific column of table, only rows with white background Macro Help Needed - White Background & PDF PJinNH Word VBA 3 05-04-2017 04:58 PM
Looking for a macro for word count in one specific column of table, only rows with white background Count # of times "text" is in 1 column is specific date is in the other column ann.acornacchio Excel 4 12-31-2016 05:40 PM
Copying specific columns of a table to WORD and deleting rows ffinley Word VBA 5 12-07-2015 04:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:23 AM.


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