Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4244282
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:41:15+00:00 2026-05-21T03:41:15+00:00

So I want to run through A1-C200 and paste everything into a Word document.

  • 0

So I want to run through A1-C200 and paste everything into a Word document. The trouble is, I have two ways of pasting it into Word, but each one has its downfall.

Goal: Copy A1-C200 into Word and keep the column layout, without copying blancs.

Example 1:

The code below copies everything into Word, but runs from A1 -> A200, B1 -> B200, C1 -> C200. Because it reads through my file this way, I lose my column layout. I would prefer a solution for this example, because this code looks clearer to me.

iMaxRow = 200

" Loop through columns and rows"
For iCol = 1 To 3
    For iRow = 1 To iMaxRow

    With Worksheets("GreatIdea").Cells(iRow, iCol)
        " Check that cell is not empty."
        If .Value = "" Then
            "Nothing in this cell."
            "Do nothing."
        Else
            " Copy the cell to the destination"
            .Copy
            appWD.Selection.PasteSpecial
        End If
    End With

    Next iRow
Next iCol

Example 2:

The code below copies the correct column layout, but also inserts blancs. So if A1-A5 and A80-A90 are filled in, I will have 75 blancs in my Word document.

a1 = Range("A1").End(xlDown).Address
lastcell = Range("C1").Address
Range(a1, lastcell).Copy
With Range("A1") 
Range(.Cells(1, 1), .End(xlDown).Cells(2, 3)).Copy
End With
Range("A1:C50").Copy
appWD.Selection.PasteSpecial
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:41:16+00:00Added an answer on May 21, 2026 at 3:41 am

    There’s multiple ways to do this, don’t know which is the quickest but here’s some code I threw together real quick for you. Getting the range all at once in a variant is the fastest way to grab data out of excel.

    Sub test()
    
            Dim i As Long, j As Long
            Dim wd As Word.Document
            Dim wdTable As Word.Table
            Dim wks As Excel.Worksheet
            Dim v1 As Variant
            Set wd = GetObject("C:\Documents and Settings\Jon\Desktop\New Microsoft Word Document.doc")
    
    'Get data in array
            Set wks = ActiveSheet
            v1 = wks.UsedRange        
    
    'Create table
            Set wdTable = wd.Tables.Add(Range:=wd.Application.Selection.Range, NumRows:=1, NumColumns:= _
                ubound(v1,2), DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
                wdAutoFitFixed)
    
    
            'Place data
            For i = 1 To UBound(v1)
                For j = 1 To UBound(v1, 2)
                    If Len(v1(i, j)) > 0 Then
                        'Add row if not enough rows, this can be done before the j loop if
                        'you know the first column is always filled.
                        'You can also do an advanced filter in excel if you know that the first
                        'column is filled always and filter for filled cells then just
                        'do a straight copy and paste using r1.specialcells(xlCellTypeVisible).copy 
                        'If you know the rows ahead of time when you create the table you can create all the rows at once,
                         'which should save time.
                        wd.application.selection
                        If wdTable.Rows.Count < i Then wdTable.Rows.Add
                        wdTable.Cell(i, j).Range.Text = v1(i, j)
                    End If
                Next j
            Next i
    
            Set wks = Nothing: Set wd = Nothing: Set v1 = Nothing
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sql script file and i want to run that i can
I have a Powershell script that is going to be run through an automation
I want to run a query on an Oracle database and for each column
I know this is a bad idea, but I have lots of legacy code
I'm using Perl to run through a tree, and then calculate the leaf nodes
I have a powershell script I want to be able to define different starting
I have a list of urls (1000+) which have been stored for over a
I'm using PHP, also a complete noob at it. So I have this URL
I am trying to connect to a MySQL database using Java. I want to
I am using python unittest module to do a number of tests; however, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.