Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How to extract data from autofiltered worksheet

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I extract data from worksheet to VBA? Bob Allen[_2_] Excel Discussion (Misc queries) 4 July 31st 09 09:49 PM
extract data from another worksheet G&GSolutions Excel Discussion (Misc queries) 0 February 25th 09 02:29 PM
extract data from worksheet T3st3r Excel Discussion (Misc queries) 0 June 19th 08 10:15 PM
Extract data from one worksheet SKY Excel Worksheet Functions 5 April 27th 06 01:48 PM
extract data from worksheet sallu Excel Worksheet Functions 2 February 21st 05 06:50 AM


All times are GMT +1. The time now is 12:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"