Jean-Guy Marcil wrote:
>
> Place those in a table as you suggested.
> Then, make sure that the first column contains only the patient
> number. After that it is easy to compare the content of each cell.
>
> If the content is different, use a message box to pop up a warning,
> something like:
>
> With Selection.Tables(1)
> If .Rows(1).Cells(1).Range.Text = .Rows(1).Cells(1).Range.Text Then
> MsgBox "ABORT, ABORT, mismatch in patient number... ABORT,
> ABORT!!!", _
> vbCritical, "Error"
> Exit Sub
> End If
> End With
Hi, Jean-Guy,
Just a gentle nudge :-) to use <> instead of = and to compare different
rows:
If .Rows(1).Cells(1).Range.Text <> .Rows(2).Cells(1).Range.Text Then
It might also be a good idea to wrap each of those expressions in a Trim()
function to avoid a mismatch only because of white space differences:
If Trim(.Rows(1).Cells(1).Range.Text) <> Trim(.Rows(2).Cells(1).Range.Text)
Then
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.