Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2022, 04:03 AM
Bikram Bikram is offline Array to table Windows 10 Array to table Office 2007
Advanced Beginner
Array to table
 
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
  #2  
Old 03-26-2022, 08:46 PM
Bikram Bikram is offline Array to table Windows 10 Array to table Office 2007
Advanced Beginner
Array to table
 
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
Reply

Tags
array to table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Array Formula Macacidic Excel 2 09-12-2017 08:19 AM
Array to table Used an Array to Add a Median to Pivot Table- Now need Median to also appear on graph jrnisaac1 Excel 3 04-25-2017 08:45 AM
Array to table looking to persist and array or something vthomeschoolmom Word VBA 1 09-16-2015 02:12 PM
Adding information from a array into a table jcorti Word VBA 4 01-10-2014 10:58 PM
Array to table Convert String Array to Integer Array from a User Input? tinfanide Excel Programming 4 12-26-2012 08:56 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:54 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft