Thread: Array to table
View Single Post
 
Old 03-25-2022, 04:03 AM
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 Array to table

Greeting to all, This time I am trying to convert arrays to the table. I have tried the following code but couldn't go further than the code posted below:
Code:
Sub arraytotable()
    Dim strfind()
    Dim strreplace()
    Dim i As Integer, k As Integer
    Dim j As Integer
    Dim t As table
    Dim ad As Document
        Set ad = Documents.Add
            strfind = Array("me","you","them","Us")
            strreplace = Array("me","you","them","Us")
            i = UBound(strfind) - LBound(strfind) + 1
        Set t = ad.Tables.Add(Selection.Range, i, 2)
    For k = 1 To 2
        For j = 1 To i
            t.Cell(i, 1).Range.InsertAfter (strfind(i).Text)
            t.Cell(i, 2).Range.InsertAfter (strreplace(i).Text)
        Next
    Next

End Sub
How can I get the job done? I am looking forward to any suggestions or guidance. Any help would be appreciated. Thanks in advance!!
Reply With Quote