Results 1 to 13 of 13

VBA help for a complete beginner - Copy and pasting from Excel to Word template

Threaded View

  1. #1
    Registered User
    Join Date
    08-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    7

    VBA help for a complete beginner - Copy and pasting from Excel to Word template

    Hello Everyone

    I am a complete novice at VBA having only picked it up a day or two ago with no previous programming experience. Here's my problem if anyone out here is able to help:

    I have created an excel document that can be used to populate a table on one of the worksheets (Switching Sequence) using a number of different drop down boxes. The choices made on the drop down boxes are shown in another table on another worksheet (Populated Table). This table on "Populated Table" needs to be copied and pasted into an existing template where it can be saved and printed off for use.

    The table consists of the following rows:

    Operation Number (column B) , Location (column C), Circuit or Device (column D), Operation (column E), Complete? (column F), Date and Time (column G)

    Is there a way in which my code is able to copy the table (range B5:G82) and then only past the rows in which there is an Operation in its corresponding D cell?

    Here is what I have already. So far it copies and pastes the whole range (B5:G82) but I am unable to make it ignore the rows with a blank in it's corresponding D column.

    Sub CopyToWord()
        Dim wd
        Dim Data As Range
        Dim Doc
    
    
         
        Set Data = Sheets("Populated Table").Range("B5:G82")
        Data.Copy
        Set wd = CreateObject("Word.Application")
        wd.Visible = True
        Set Doc = wd.Documents.Add(Template:="C:\Users\user\Documents\Work\Switching Program\test2.docx")
        wd.Selection.Paste
        
        Application.CutCopyMode = False
         
    End Sub
    I will attach my excel sheet so if anyone has chance they can have a proper look at it.

    So in summary I want to be able to:

    1. Populate table in Excel
    2. Copy table
    3. Paste table in word template but without the rows with a blank cell in its D column


    Any help would be amazing

    Many thanks

    AM2809
    Attached Files Attached Files
    Last edited by am2809; 08-16-2017 at 04:09 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to copy word to excel for beginner
    By maiser in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-28-2017, 04:08 AM
  2. VBA Excel to Word copy and pasting
    By JimmyWilliams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2017, 06:45 PM
  3. [SOLVED] Copy contacts from Excel to a Word label template
    By Casperinoz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2013, 12:30 AM
  4. Importing multiple text files into Excel, for a complete beginner
    By halldin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 07:52 AM
  5. [SOLVED] Pasting Excel Values To Word Template - PROBLEM, NEED SOLVED URGENT
    By TheProffesional in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-14-2012, 10:25 PM
  6. excel copy cells to word template
    By Garr in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 08-07-2006, 11:35 PM
  7. excel copy cells to word template
    By gtpighin@shaw.ca in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-05-2006, 05:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1