Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Terry D Terry D is offline
external usenet poster
 
Posts: 2
Default How do I replace non-constants in word?

Is there any way that I can replace in word when something is not constant? I
am copying columns over from Excel. Some are in two columns and some are in
three. A, B and C change on each line

For example I need to replace
A tab tab B tab tab C
with
A tab B tab C

I can't just replace tab tab with tab as this affects the two column and I
end up with A tab C. Do I use a wildcard and if so how do I do it?

Many thanks for any help you can give
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jean-Guy Marcil[_2_] Jean-Guy Marcil[_2_] is offline
external usenet poster
 
Posts: 373
Default How do I replace non-constants in word?

"Terry D" wrote:

Is there any way that I can replace in word when something is not constant? I
am copying columns over from Excel. Some are in two columns and some are in
three. A, B and C change on each line

For example I need to replace
A tab tab B tab tab C
with
A tab B tab C

I can't just replace tab tab with tab as this affects the two column and I
end up with A tab C. Do I use a wildcard and if so how do I do it?


I am sorry, but I don't follow.

If, as you write, you have

A tab tab B tab tab C

and you do a Find/Replace where you replace "tab tab" by "tab," you will
end up with

A tab B tab C

not

A tab C
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Terry D Terry D is offline
external usenet poster
 
Posts: 2
Default How do I replace non-constants in word?



"Jean-Guy Marcil" wrote:

"Terry D" wrote:

Is there any way that I can replace in word when something is not constant? I
am copying columns over from Excel. Some are in two columns and some are in
three. A, B and C change on each line

For example I need to replace
A tab tab B tab tab C
with
A tab B tab C

I can't just replace tab tab with tab as this affects the two column and I
end up with A tab C. Do I use a wildcard and if so how do I do it?


I am sorry, but I don't follow.

If, as you write, you have

A tab tab B tab tab C

and you do a Find/Replace where you replace "tab tab" by "tab," you will
end up with

A tab B tab C

not

A tab C


Sorry it's a bit confusing:

What I'm trying to do is replace the following:

John [tab][tab]Michael [tab][tab]Jones
John[tab][tab]Smith
so can copy back into excel (where the [tab] is a column break
I need the [tab][tab]Michael[tab][tab] to be [tab]Michael][tab] where
Michael is a variable.

if I replace [tab][tab] with [tab] it changes the John Smith line and that
needs to stay the same.

Hope this makes more sense.
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Herb Tyson [MVP] Herb Tyson [MVP] is offline
external usenet poster
 
Posts: 2,936
Default How do I replace non-constants in word?

Am I correct that two consecutive tabs corresponds to an empty cell between
those two tabs? And, a line that begins with a tab indicates that the 1st
cell in that row is empty?

If so, I'd do this in multiple steps, and replace all of the empty cells
with token placeholders you can delete later on.

1. Find:^p^t
Replace:^p[placeholder]^t

This puts a placeholder at the begging of any row with an empty first cell.

2. Find:^t^t
Replace:^t[placeholder]^t

This puts placeholders in the interior for any empty cell.

3. Find:^t^p
Replace:^t[placeholder]^p

This puts a placeholder at the end of any row with an empty last cell.

But.. a bigger question is "Why do you have tabs at all?" When pasting
to/from Excel, it's possible to paste as a Word table, then paste back into
Excel's row/column structure, which are far easier to work with than tabbed
columns.

--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com


"Terry D" Terry wrote in message
...
Is there any way that I can replace in word when something is not
constant? I
am copying columns over from Excel. Some are in two columns and some are
in
three. A, B and C change on each line

For example I need to replace
A tab tab B tab tab C
with
A tab B tab C

I can't just replace tab tab with tab as this affects the two column and I
end up with A tab C. Do I use a wildcard and if so how do I do it?

Many thanks for any help you can give


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Jean-Guy Marcil[_2_] Jean-Guy Marcil[_2_] is offline
external usenet poster
 
Posts: 373
Default How do I replace non-constants in word?

"Terry D" wrote:

Sorry it's a bit confusing:

What I'm trying to do is replace the following:

John [tab][tab]Michael [tab][tab]Jones
John[tab][tab]Smith
so can copy back into excel (where the [tab] is a column break
I need the [tab][tab]Michael[tab][tab] to be [tab]Michael][tab] where
Michael is a variable.

if I replace [tab][tab] with [tab] it changes the John Smith line and that
needs to stay the same.


Try this:

Find What:
([A-z0-9 ]@^t)^t([A-z0-9 ]@^t)^t([A-z0-9 ]@^13)
Replace with:
\1\2\3

Make sure to turn on the Wild card option (Click on More first).

The above means:
([A-z0-9 ]@^t) = [any letter, any number or space]any number of occurences
of the preceding(@) followed by a tab(^t). The ( ) indicate that this is
group.

^t = a tab (Not part of any groups, it is not in between any pair of
brackets.)

([A-z0-9 ]@^t)^t = [any letter, any number or space]any number of occurences
of the preceding followed by a tab. The ( ) indicate that this is group.

^t = a tab

([A-z0-9 ]@^13)= [any letter, any number or space]any number of occurences
of the preceding followed by a paragraph mark(ΒΆ). The ( ) indicate that this
is group.

Replace with
\1 = The first group
\2 = The second group
\3 = The third group

So, this deletes the extra tabs.


  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How do I replace non-constants in word?

Replace
^t(^t[A-Za-z]{1,}^t)^t
with
\1
with the wildcard option set
http://www.gmayor.com/replace_using_wildcards.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Terry D wrote:
"Jean-Guy Marcil" wrote:

"Terry D" wrote:

Is there any way that I can replace in word when something is not
constant? I am copying columns over from Excel. Some are in two
columns and some are in three. A, B and C change on each line

For example I need to replace
A tab tab B tab tab C
with
A tab B tab C

I can't just replace tab tab with tab as this affects the two
column and I end up with A tab C. Do I use a wildcard and if so how
do I do it?


I am sorry, but I don't follow.

If, as you write, you have

A tab tab B tab tab C

and you do a Find/Replace where you replace "tab tab" by "tab," you
will end up with

A tab B tab C

not

A tab C


Sorry it's a bit confusing:

What I'm trying to do is replace the following:

John [tab][tab]Michael [tab][tab]Jones
John[tab][tab]Smith
so can copy back into excel (where the [tab] is a column break
I need the [tab][tab]Michael[tab][tab] to be [tab]Michael][tab] where
Michael is a variable.

if I replace [tab][tab] with [tab] it changes the John Smith line and
that needs to stay the same.

Hope this makes more sense.



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Jean-Guy Marcil[_2_] Jean-Guy Marcil[_2_] is offline
external usenet poster
 
Posts: 373
Default How do I replace non-constants in word?



"Graham Mayor" wrote:

Replace
^t(^t[A-Za-z]{1,}^t)^t


or

^t(^t[A-z0-9 ]@^t)^t

in case there are numbers or spaces...


Much more elegant to look only for the middle column instead of the whole
line as I did!
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
replace variables (auto-numbered paragraph numbers) with constants zapspan Microsoft Word Help 4 March 3rd 08 01:59 PM
how to change constants in a word document with drop downs Cheer Coach Microsoft Word Help 2 February 8th 07 06:38 PM
VBA in Word 2003 - headerfooter constants Jacqui Lane Page Layout 1 August 2nd 06 02:54 PM
Document Constants Murtaza Microsoft Word Help 2 November 18th 05 09:08 AM
Enumeration constants Ron Ford Mailmerge 1 December 22nd 04 02:29 AM


All times are GMT +1. The time now is 12:25 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"