Re: finding within an only table column

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Oh... that's not good...

each cell a word... the application will slow too much... I think I will
store all the texts of the first column into an external range, and perform
the searches within this range, using the paragraph number to identify de
respective table row...

Thanks, Greg

Regards,

Pablo

--
Pablo Cardellino
Florianópolis, SC
Brazil

"Greg Maxey" <gmaxey@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> escreveu na
mensagem news:urXoBNZgJHA.4864@xxxxxxxxxxxxxxxxxxxxxxx
AFAIK, you can't define a column as search range explicitly. What you
can do is search each cell in a specific column only:

Sub ScratchMacro()
Dim oRng As Word.Range
Dim oCell As Word.Cell
'Find and replace in column 3 only.
For Each oCell In ActiveDocument.Tables(1).Columns(3).Cells
Set oRng = oCell.Range
With oRng.Find
.Text = "Text to find"
.Replacement.Text = "Replacement Text"
.Execute Replace:=wdReplaceAll
End With
Next oCell
End Sub


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"Pablo Cardellino" <pablocardellino.listas@xxxxxxxxx> wrote in message
news:eES1DnYgJHA.5844@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm trying to perform a search within a certain column of a table.
Find.Execute must not match any word within the other table columns. But
this is right what happens. The Find find terms within the first column,
but find terms within de second column too.

First I'll paste the code (explained) that defines the range, which seems
to be the origin of the problem:

Set termosdic = dicDoc.Tables(1).Cell(2, 1).Range
'I begin from the second row to jump
' the header cell (which I can delete,
' if necessary)

termosdic.Select

Selection.MoveDown unit:=wdLine, Count:=dicDoc.Tables(1).Rows.Count -
2, _
Extend:=wdExtend
' I didn't achieve to do this withous
' the Selection object

Selection.Font.Color = wdColorRed
' this colors the first column cells,
' except for the Cell(1,1)

Set termosdic = Selection.Range
termosdic.Font.Color = wdColorBlue
' this colors almost all the table,
' from the Cell(2,1) up to the last
' cell of the first column, *including*
' the cells of the other columns,
' except the ones of the last row (just
' as if I'd select using the mouse)

termosdic.Select
' just for testing purpouses: this
' selects the same thas was previously
' selected, despite the previous
' coloring action





And this is the search, which should match just terms from the first
column:

With loctermosdic.Find
.Text = LCase(termo.Text)
.MatchWildcards = False
.MatchWholeWord = True
.Wrap = wdFindStop

termoachado = False

Do: While .Execute
If .Found Then
Set ch = loctermosdic.Duplicate
ch.SetRange Start:=ch.Start - 1, End:=ch.Start
If ch.Text <> "-" Then
ch.SetRange Start:=loctermosdic.End,
End:=loctermosdic.End + 1
If ch.Text <> "-" Then
termoachado = True
loctermosdic.Select
Exit Do
End If
End If
End If
Wend: Exit Do: Loop
End With


Any help will be most appreciated

Thanks in advance,
Pablo

--
Pablo Cardellino
Florianópolis, SC
Brazil





.



Relevant Pages

  • Re: MS Word drop downs
    ... being in separate paragraphs in the corresponding cell in the second column. ... Now load the Area listbox by iterating through the cells of the first column ... noted titles only pertain to Procurement Area). ...
    (microsoft.public.word.vba.general)
  • RE: VLOOKUP matches
    ... Since the number in the first column are in order 1, A1+1,... ... preformatting the cell to Text ... You can not tell by checking the Format. ... random numbers from 1 to the total current number of employees. ...
    (microsoft.public.excel.misc)
  • Re: Can I Use a Count Function for Text?
    ... For example, my first column has the letters A, B, C, D or no letters at ... The second column has different descriptive words (i.e. internal ... I would like a cell to be counted if a cell ...
    (microsoft.public.excel.worksheet.functions)
  • Word vba Table
    ... cell content of first column on first page and copying into second cell of ... first column on second page,I extended it to copy last non empty cell ... >> Goto first page and select non empty cell from last in the first column. ... > Dim rngCell1 As Word.Range ...
    (microsoft.public.word.vba.customization)
  • Re: Removing a Row based on a cell value
    ... The example below will copy all rows with the value "Netherlands" in the first column of the range ... You can also use another cell then A1 in your table but I like to use the top left cell of the filter range that ... Dim WSNew As Worksheet ... On Error GoTo 0 ...
    (microsoft.public.excel.misc)