Quote:
Originally Posted by mrsandes
Hi Paul,
Thanks for sharing this amazing macro, it is working.
However, I have tried modifying a few things to make it simpler without success... I wanted to have the generated table as only 2 columns, the abbreviations and the meaning. I would like to run a validation test on the abbreviations and meanings generated as well based on a pre-defined list that I have, to make sure only pre-approved abbreviations were used and with the pre-assigned meaning to them.
Would you see that as a possible thing with VBA?
|
I managed to get the validation part up and running using a third column to show the "result". The only thing I am struggling with now is taking out everything related to what the columns 3 to 5 did in the default macro and having the macro creating only 3 columns... Your help would be much appreciated.
Macro used for validation:
Code:
Sub Validate()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long, Abb_Fd As String, Def_Fd As String, x As Long
Dim accept As String, reject1 As String, reject2 As String
accept = "Approved"
reject1 = "Unapproved Abbreviation/Acronym"
reject2 = "Unapproved Definition to Abbreviation/Acronym"
Dim arrTerms(1, 1)
arrTerms(0, 0) = "A/C"
arrTerms(1, 0) = "AAR"
arrTerms(0, 1) = "Aircraft"
arrTerms(1, 1) = "Aircraft Architecture Review"
With ActiveDocument
Set Tbl = .Tables(.Tables.Count)
For r = 2 To Tbl.Rows.Count
Abb_Fd = Split(Tbl.Cell(r, 1).Range.Text, vbCr)(0)
Def_Fd = Split(Tbl.Cell(r, 2).Range.Text, vbCr)(0)
For x = 0 To 364
If Abb_Fd = arrTerms(x, 0) And Def_Fd = arrTerms(x, 1) Then
Tbl.Cell(r, 3).Range = accept
Exit For
ElseIf Abb_Fd = arrTerms(x, 0) Then
Tbl.Cell(r, 3).Range = reject2
Exit For
Else: Tbl.Cell(r, 3).Range = reject1
End If
Next x
Next r
End With
Application.ScreenUpdating = True
End Sub