![]() |
#1
|
|||
|
|||
![]()
I'm looking to take some data from Excel and paste it to Word as tables. So, with this Excel data there would end up being six separate tables in Word.
I've been working with a couple of threads with a possible solution, but just not getting the syntax right. This will just be written to a new word doc. If found the following code and also the code from this most recent post. This of course works great, but now to loop thru the ranges. Code:
Sub Demo() Dim wdApp As New Word.Application Dim wdDoc As Word.Document ActiveSheet.Range("A2").Resize(4, 2).Copy With wdApp .Visible = True Set wdDoc = .Documents.Add With wdDoc .Range.PasteExcelTable False, False, True End With End With Set wdDoc = Nothing: Set wdApp = Nothing Application.CutCopyMode = False End Sub Code:
Sub LoopthruRange() Dim Rng As Range With Range("A2", Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants) For Each Rng In .Areas Rng.Resize(, 2).Copy Next Rng End With End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Auto populate form (data from excel) in Word based on drop down list selection (data from excel) | wvlls | Word VBA | 1 | 03-22-2019 02:29 PM |
Open Excel, copy & paste data & chart | Tal71 | Word VBA | 2 | 08-14-2018 08:28 PM |
![]() |
cory_0101 | Word | 4 | 10-17-2012 12:30 PM |
How to Copy data from Outlook mail and Paste it in a Excel sheet? | padhu1989 | Outlook | 0 | 09-11-2012 04:07 AM |
Using Paste/Special wih Excel data | chickasaw | PowerPoint | 0 | 02-05-2010 10:00 PM |