Consulting

Results 1 to 2 of 2

Thread: Copying data from Excel to pre-existing Word table

  1. #1
    VBAX Regular
    Joined
    May 2020
    Posts
    6
    Location

    Exclamation Copying data from Excel to pre-existing Word table

    Hi friends,
    I have provided a sample excel and word file for better understanding the task I want to do. I have an Excel file which contains some information about PM services. In the provided Word file, you see that there is a page with a table (Pre-Existing).
    I want to copy each cell in the Excel file to the corresponding cell in the Word table. My Excel file may contain around 1300 rows, so I need to add the same Word page with the same text and table style as I need to fill all those 1300 rows in Word file (the sample file has 99 data rows).
    Please guide me to write a VBA code for automating this task.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,635
    You'd better paste the data into an empty Word document and format it afterwards:

    Sub M_snb()
       Sheet1.Cells(1).CurrentRegion.Offset(1).SpecialCells(2).Copy
       
       With GetObject("J:\download\Test(1).docx")
          .Paragraphs.last.Range.Paste
        End With
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •