help with macro

D

Dorothy

I have a document with multiple tables (separated). What I would like to do is create a macro that selects a certain table and then pulls out only the rows that have text in the second column and puts these rows at the bottom of the document as a new page. The table has four columns. First column has a few lines of text describing an action that has to be taken (this is a "minutes" document). The second column will have a name of the person that is responsible for the action (Last name, first name). The third column would have a due date. So really what I want is to pull out just the action items, which would be the rows with a person's name in the second column, and list them on a separate page at the bottom of the document. Also would like it to be sorted by ascending alpha order by person's name. I have done macros using tools - macros and recording the macro while performing certain steps. I believe I would have to use VB code and I am not real familiar with that. I hope this makes sense.

Just another thought. Would it make more sense to create fields using table of contents fields? This way if I update the body of the document it would also update the summary page at the end of the document. Thank you for any help you can give.

Dorothy
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Dorothy,

Use

Dim i As Long, myrange As Range
ActiveDocument.Range.InsertAfter vbCr
Set myrange = ActiveDocument.Range
myrange.Collapse wdCollapseEnd
For i = 1 To Selection.Tables(1).Rows.Count
If Len(Trim(Selection.Tables(1).Cell(i, 2).Range)) > 2 Then
ActiveDocument.Range.InsertAfter Selection.Tables(1).Cell(i,
2).Range
End If
Next i
myrange.End = ActiveDocument.Range.End - 1
myrange.Sort


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 
D

Dorothy

Hi Doug,

Thank you for your help. I am going to give it a try. Again, this is all new to me and really not sure where to put this code. If I get completely lost, I will be back. Thanks again.
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Dorothy,

See the article “What do I do with macros sent to me by other newsgroup
readers to help me out?” at:

http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

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