PDA

View Full Version : [SOLVED:] Range copy issue when transforming excel to word



haudrauf64
03-25-2022, 05:11 AM
Hi There

I have to export certain columns from an excel sheet to a word document.
Problem:
ActiveSheet.Range("B:B , D: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

29550



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

Aflatoon
03-25-2022, 06:04 AM
Hide column C, then copy B:D and paste, then unhide column C again.

haudrauf64
03-25-2022, 06:24 AM
thank you! so simple!