![]() |
#1
|
|||
|
|||
![]()
Hi everyone.
I have a table with two hundred plus rows. I would like to be able to find the rows that have the word "Draft" in the 3rd column. I then want to copy the entire row, loop through the rest of the table while finding and copying, and then paste into a new document. I think it will have to be macro code and this is beyond my abilities. The table is eight columns if that matters. The word Draft is not the only word in column 3. Oh and column 3 is a hyperlink but does not have to be pasted as a hyperlink. Carol |
#2
|
||||
|
||||
![]()
Hi Carol,
Try: Code:
Sub Demo() Dim DocSrc As Document, DocTgt As Document, Tbl As Table, TblRw As Row Set DocSrc = ThisDocument Set DocTgt = ActiveDocument With DocSrc For Each Tbl In .Tables For Each TblRw In Tbl.Columns(3).Cells With TblRw.Range If InStr(.Text, "Draft") > 0 Then .Rows(1).Range.Copy DocTgt.Range.Characters.Last.Paste End If End With Next Next End With Set DocSrc = Nothing: Set DocTgt = Nothing End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thanks Paul - Tried it out but can't get it to work. I get a Run-time error #424. Obect Required.
The debugger stops at my file names which I changed as follows: Set DocSrc = IndexSource.docx Set DocTgt = IndexTarget.docx Do I need the path? Thanks for you help. |
#4
|
||||
|
||||
![]()
Those variable references are to documents, not just document names. The code I posted assumes you've opened the documents and therefore need only to tell the macro which is which. As coded, the macro assumes it is in the source document, which isn't the active one, and that the active document is the target document.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]() Quote:
Carol |
#6
|
||||
|
||||
![]()
You have two documents:
1. A source document 2. A target document The macro is coded on the assumption that it is placed in the source document. Open the source document, press Alt-F11 to open the VBE, and add the macro to that document. Press Alt-F11 again to return to the document. Then open the target document (or, if it's already open, make that document the active one). Then press Alt-F11 to open the VBE, select the macro (in the source document) and press F5 to run it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
joflow21 | Excel | 9 | 11-22-2013 12:10 PM |
Why cant I just copy/paste new flippin rows into a flippin table? | jethrouk | Word | 8 | 11-17-2013 06:09 PM |
![]() |
tinfanide | Word | 6 | 03-06-2013 12:21 AM |
![]() |
khalidfazeli | Excel | 2 | 02-06-2013 09:38 AM |
![]() |
jperez84 | Word VBA | 24 | 09-20-2012 11:34 AM |