View Single Post
 
Old 06-29-2018, 11:11 AM
d4okeefe d4okeefe is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

To get the text into two columns, you can do something like this. Notice that variables arr1 and arr2 already need to be filled with your data.

I hope that helps. Better yet, as I mentioned, it might be good to see your code. Since you aren't terribly used to working with VBA, it would be easy to have a variable misnamed or out of place.

Code:
    Dim tbl As Table
    Set tbl = new_doc_rng.Tables.Add(new_doc_rng, 2, 2)
    
    tbl.Cell(1, 1).Range.Text = "Countries from Doc1:"
    tbl.Cell(1, 2).Range.Text = "Countries from Doc2:"
    
    Dim countries1_as_string As String
    For x = 1 To UBound(arr1)
        If arr1(x) <> "" Then
            countries1_as_string = _
                countries1_as_string & arr1(x) & Chr(10)
        End If
    Next x
    tbl.Cell(2, 1).Range.Text = countries1_as_string
    
    Dim countries2_as_string As String
    For x = 1 To UBound(arr1)
        If arr1(x) <> "" Then
            countries2_as_string = _
                countries2_as_string & arr2(x) & Chr(10)
        End If
    Next x
    tbl.Cell(2, 2).Range.Text = countries2_as_string
Reply With Quote