Import filtered data into a word document

O

Obonden

Is it possible to make a word-report from excel, where the data is divided
in groups based on different criterias?

An example, where towns starting on S i chosen first, then towns on O next:

Wordtext text text ....

Stockholm, Sweden
Sevilla, Spain
Sandefjord, Norway

More text, more text, more text ....

Oslo, Norway
Ohio, USA

And so on... - or are there any other solution on presenting multiple-sorted
data?
 
C

CurlyDave

This code when run from Excel will copy your filtered data from Excel
and paste it into a specific Word Doc. Be careful where your cursor is
in the doc as it will paste where the cursor is.

Sub CopyFilteredDataToWord()

Dim wdApp As Word.Application, wdDoc As Word.Document

On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wdDoc = wdApp.Documents.Open("C:\Excel Forums
\LinkedToWord.doc") 'change the location and Doc Name
wdApp.Visible = True
Sheet2.AutoFilter.Range.Copy 'change sheet name of filtered data
wdApp.Selection.Paste
Application.CutCopyMode = False
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top