Hi Serguey:
Here's an excerpt of a macro that searches for a nominated string in a table
cell:
SearchString = myRange.Cells(2).Range.Text ' The Title cell
If Len(SearchString) < 13 Or _
InStr(SearchString, "<") <> 0 Or _
InStr(SearchString, ">") <> 0 Then
myAction = MsgBox("The Title cell text in the Logo Table is the wrong
length or still contains < or >." _
& vbLf & "Would you like to insert a new set of header tables?",
vbInformation + _
vbYesNoCancel, "Check Tables Macro")
End If
If myAction = 6 Then
GoTo DoHeaderTable
ElseIf myAction = 2 Then
GoTo AllDone
End If
MyRange is a range that consists of the entire table. You need to use a
range because you cannot iterate the cells of a table unless it has a
uniform number of cells in each row. Many users tables include merged rows
or columns: to overcome that, address each cell as (table).Cells(<number>).
The Length of the text range of a table cell will be "1" if the cell is
empty (i.e. Contains only the end of cell marker).
The statement InStr(SearchString, "<") <> 0 returns the character position
from the start of the text string in which we found a "<" character. In
this case, if we found one at all, the user has not completed a "<Put title
here>" field, and that's what we wanted to know. That test will return 0 if
there is no instance of the < character in the string.
Hope this helps
I have a tale for text entries in Word (Not Excel).
I need to make sure that a macro finds an empy cell in a given column.
If all cells in this column are not empty, the macro should create a new row.
I can arrive to the needed table, find a column - but I cannot find a way
to make a check:
If a cell is not empty, move down to a cell below, if there is none, create
a new row.
If a cell is NOT empty, copy a string into it.
Could you help, please?
Thank you in advance.
Serguey
--
Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.
John McGhie <
[email protected]>
Microsoft MVP, Word and Word for Macintosh. Business Analyst, Consultant
Technical Writer.
Sydney, Australia +61 (0) 4 1209 1410