View Single Post
 
Old 04-01-2021, 05:16 AM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 mbcohn View Post
But there were only four rows. Now if I want to change the code to have it search for more things, I have to play around with that expression.
Well, that's a consequence of you not properly specifying your requirements from the outset...
Quote:
Originally Posted by mbcohn View Post
Could you please show me how to do it with just a loop, so I'll know?
When I started out on this thread, I didn't even know which table in the document you're referring to or how the table(s) are structured - not even which column the data of interest might be in. All you originally said was:
Quote:
Originally Posted by mbcohn View Post
I have a series of documents that all contain identical formatting.
Each has a table that contains a cell with the value "Revision No."
Given that I still don't know how many tables there are, you might use code like:
Code:
Dim Tbl As Table, r As Long
For Each Tbl In wdDoc.Tables
  With Tbl
    For r = 1 To .Rows.Count
      Select Case Trim(Split(.Cell(r, 1).Range.Text, vbCr)(0))
        Case "Revision No.": .Cell(r, 2).Range.Text = "2.5"
        Case "Published": .Cell(r, 2).Range.Text = "2 April 2021"
      End Select
    Next
  End With
Next
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote