Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am struggling to learn VBA! Thanks for all the good advice and tips in this forum. I am making a VBA application that extracts information from a spreadsheet and creates word-documents based on that information. I use autofilter to choose which data is to be extracted and inserted in the word-file. I used someones great example here in this forum (thanks again) and modified it slightly, and it runs perfect. However, that code does not stop until all data has been copied (which is fine in that case). Now in this case I have tried to adapt the code so that it extracts four fields that are to be inserted at bookmark places in a word document. I think I would succeed if I only could get myRef to point to the a known position (let's say top left) and then offset from there. But I just cannot seem to figure it out. Any advice to a frustrated beginner will be greatly appreciated! Thanks, Peter Dim rng As Range Dim rng1 As Range Dim cell As Range Dim myRef As Variant Set rng = ActiveSheet.Autofilter.Range.Columns(1) Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count, 1) Set rng1 = rng.SpecialCells(xlVisible) If Not rng1 Is Nothing Then ' there are visible rows besides the header ' Something is missing here? 'inserts text in Word at bookmarks from offset position With wdApp.ActiveDocument .Bookmarks("myNamnplats").Range.InsertAfter CStr(Range rng).Cells.Offset(0, 2).Value) .Bookmarks("myAntalPortplats").Range.InsertAfter CStr(Range(myRef).Offset(1, 2).Value) .Bookmarks("myVersionplats").Range.InsertAfter CStr(Range(myRef).Offset(2, 2).Value) .Bookmarks("myIntrTextplats").Range.InsertAfter CStr(Range(myRef).Offset(3, 2).Value) End With End If -------- Peter Sebelius |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I extract data from worksheet to VBA? | Excel Discussion (Misc queries) | |||
extract data from another worksheet | Excel Discussion (Misc queries) | |||
extract data from worksheet | Excel Discussion (Misc queries) | |||
Extract data from one worksheet | Excel Worksheet Functions | |||
extract data from worksheet | Excel Worksheet Functions |