Rakesh
08-14-2010, 01:25 PM
:help
Hi Rocks,
I had created a macro for replacement using wildcards. It works fine. But what I need is, it should be run in certain condition only.
The condition is, If the line starts with the word “Series” after the Heading, the macro should run upto the next Heading (Like that throughout the Document)
Can it possible to do it?
Below is the Coding, Sample Data and Output Data for your reference
Sub series()
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([!\n0-9]@)\n([!\n0-9]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2^t\3^t\4", _
replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([!\n0-9]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2^t\3", _
replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2", _
replace:=wdReplaceAll
End Sub
SAMPLE DATA
FA Educational Facilities Authority (Heading)
College of Arts,
Series 2005:
5.000% 06/01/26 1,000,000 892,930
5.000% 06/01/35 1,500,000 1,252,395
California Lutheran University,
Series 2008,
5.750% 10/01/38 3,000,000 3,029,730
FA University (Heading)
Series 2007,
Insured: AGMC
4.500% 05/15/35 4,000,000 3,917,480
Series 2009 A,
6.000% 11/01/40 2,000,000 2,193,680
Series 2009 O,
5.250% 05/15/39 4,000,000 4,282,120
Series 2010 A,
5.000% 11/01/30 2,995,000 3,073,259
FA Statewide Communities Development Authority (Heading)
College for Certain LLC,
Series 2010,
GTY AGMT: PCSD Guaranty Pool LLC
6.000% 07/01/30 2,000,000 2,007,840
Crossroads School for Arts<\!s>& Sciences,
Series 1998,
6.000% 08/01/28 (a) 1,645,000 1,588,264
FA Health Facilities Financing Authority (Heading)
OUTPUT DATA
FA Educational Facilities Authority (Heading)
College of Arts,
Series 2005:
5.000% 06/01/26 1,000,000 892,930
5.000% 06/01/35 1,500,000 1,252,395
California Lutheran University,
Series 2008,
5.750% 10/01/38 3,000,000 3,029,730
FA University (Heading)
Series 2007, Insured: AGMC 4.500% 05/15/35 4,000,000 3,917,480
Series 2009 A, 6.000% 11/01/40 2,000,000 2,193,680
Series 2009 O, 5.250% 05/15/39 4,000,000 4,282,120
Series 2010 A, 5.000% 11/01/30 2,995,000 3,073,259
FA Statewide Communities Development Authority (Heading)
College for Certain LLC,
Series 2010,
GTY AGMT: PCSD Guaranty Pool LLC
6.000% 07/01/30 2,000,000 2,007,840
Crossroads School for Arts<\!s>& Sciences,
Series 1998,
6.000% 08/01/28 (a) 1,645,000 1,588,264
FA Health Facilities Financing Authority (Heading)
Thanks in Advance
Rakesh
Hi Rocks,
I had created a macro for replacement using wildcards. It works fine. But what I need is, it should be run in certain condition only.
The condition is, If the line starts with the word “Series” after the Heading, the macro should run upto the next Heading (Like that throughout the Document)
Can it possible to do it?
Below is the Coding, Sample Data and Output Data for your reference
Sub series()
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([!\n0-9]@)\n([!\n0-9]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2^t\3^t\4", _
replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([!\n0-9]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2^t\3", _
replace:=wdReplaceAll
ActiveDocument.Content.Find.Execute _
FindText:="(Series[!\n]@)\n([0-9][!\n]@[0-9]\n)", _
MatchWildcards:=True, _
ReplaceWith:="\1^t\2", _
replace:=wdReplaceAll
End Sub
SAMPLE DATA
FA Educational Facilities Authority (Heading)
College of Arts,
Series 2005:
5.000% 06/01/26 1,000,000 892,930
5.000% 06/01/35 1,500,000 1,252,395
California Lutheran University,
Series 2008,
5.750% 10/01/38 3,000,000 3,029,730
FA University (Heading)
Series 2007,
Insured: AGMC
4.500% 05/15/35 4,000,000 3,917,480
Series 2009 A,
6.000% 11/01/40 2,000,000 2,193,680
Series 2009 O,
5.250% 05/15/39 4,000,000 4,282,120
Series 2010 A,
5.000% 11/01/30 2,995,000 3,073,259
FA Statewide Communities Development Authority (Heading)
College for Certain LLC,
Series 2010,
GTY AGMT: PCSD Guaranty Pool LLC
6.000% 07/01/30 2,000,000 2,007,840
Crossroads School for Arts<\!s>& Sciences,
Series 1998,
6.000% 08/01/28 (a) 1,645,000 1,588,264
FA Health Facilities Financing Authority (Heading)
OUTPUT DATA
FA Educational Facilities Authority (Heading)
College of Arts,
Series 2005:
5.000% 06/01/26 1,000,000 892,930
5.000% 06/01/35 1,500,000 1,252,395
California Lutheran University,
Series 2008,
5.750% 10/01/38 3,000,000 3,029,730
FA University (Heading)
Series 2007, Insured: AGMC 4.500% 05/15/35 4,000,000 3,917,480
Series 2009 A, 6.000% 11/01/40 2,000,000 2,193,680
Series 2009 O, 5.250% 05/15/39 4,000,000 4,282,120
Series 2010 A, 5.000% 11/01/30 2,995,000 3,073,259
FA Statewide Communities Development Authority (Heading)
College for Certain LLC,
Series 2010,
GTY AGMT: PCSD Guaranty Pool LLC
6.000% 07/01/30 2,000,000 2,007,840
Crossroads School for Arts<\!s>& Sciences,
Series 1998,
6.000% 08/01/28 (a) 1,645,000 1,588,264
FA Health Facilities Financing Authority (Heading)
Thanks in Advance
Rakesh