Thread: Array to table
View Single Post
 
Old 03-26-2022, 08:46 PM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 94
Bikram is on a distinguished road
Default

I figured it out!! In case of anyone who may need it in the future here is the code.
Code:
Sub arraytotable()
Dim strfind(), strreplace(), i As Integer, j As Integer, t As table, ad As Document
Set ad = Documents.Add
strfind = Array("Is","Am","they","It","Or")
strreplace = Array("is","am","They","it","or")

i = UBound(strfind) - LBound(strfind) + 1
    Set t = ad.Tables.Add(Selection.Range, i, 2)
        For j = 1 To UBound(strfind)
            t.Cell(j, 1).Range.Text = strfind(j)
            t.Cell(j, 2).Range.Text = strreplace(j)
        Next
End Sub
Reply With Quote