Consulting

Results 1 to 3 of 3

Thread: Range copy issue when transforming excel to word

  1. #1

    Range copy issue when transforming excel to word

    Hi There

    I have to export certain columns from an excel sheet to a word document.
    Problem:
    ActiveSheet.Range("B:B , D").Copy does not copy only Column B and D but also every column in between (in test document column c also gets pasted).

    How do I get rid of this? I only want Column B and D, nothing else.

    Thank you for your help in advance!
    Greetz

    testsheet.xlsm

    Sub export_excel_to_word()    
        Set obj = CreateObject("Word.Application")
        obj.Visible = True
        Set newObj = obj.Documents.Add
        ActiveSheet.Range("B:B, D:D").Copy
        newObj.Range.Paste
        Application.CutCopyMode = False
        obj.Activate
    End Sub
    Last edited by haudrauf64; 03-25-2022 at 05:18 AM. Reason: code added

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,618
    Location
    Hide column C, then copy B:D and paste, then unhide column C again.
    Be as you wish to seem

  3. #3
    thank you! so simple!

Posting Permissions

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