It is unpleasantly hot - mid thirties and very high humidity
I'm off
to the mountains to cool down. When I get back I'll fix the macro to
work with your document
Glad your enjoying a warm summer's day
Thanks for your quick reply. I think if I give you the website address
it would be easier for you to get the information you need.
www.supernovabots.com/prices_0.txt
This is a list used in an online game, please ignore the names to the
right of the list I have a small script that removes them.
Thanks for your help
Dave
Working on the premise that the space is made by a tab character and
having nothing better to do on a very hot Sunday afternoon - the
following might work for you
Dim oPara As Paragraph
Dim oRng As Range
Dim i As Long
Dim iLow As String, iHigh As String
For Each oPara In ActiveDocument.Paragraphs
Set oRng = oPara.Range
oRng.End = oRng.End - 1
Select Case oRng.Words.Count
Case Is = 6
If oRng.Words(5).Text = Chr(9) Then
iHigh = oRng.Words(6)
iLow = Format(iHigh + (iHigh * 0.25), "0.00")
oRng.Words(5).Text = iLow & ",0,"
oRng.InsertAfter ",0"
End If
If oRng.Words(6).Text = Chr(9) Then
iLow = oRng.Words(5)
iHigh = Format(iLow - (iLow * 0.25), "0.00")
oRng.Words(6).Text = ",0," & iHigh
Set oRng = oRng.Paragraphs(1).Range
oRng.End = oRng.End - 1
oRng.InsertAfter ",0"
End If
Case Is = 7
If oRng.Words(6).Text = Chr(9) Then
oRng.Words(6).Text = ",0,"
oRng.InsertAfter ",0"
End If
Case Is = 8
If oRng.Words(5).Text = Chr(9) Then
iHigh = oRng.Words(6) & oRng.Words(7) & oRng.Words(8)
iLow = Format(iHigh + (iHigh * 0.25), "0.00")
oRng.Words(5).Text = iLow & ",0,"
oRng.InsertAfter ",0"
End If
If oRng.Words(8).Text = Chr(9) Then
iLow = oRng.Words(5) & oRng.Words(6) & oRng.Words(7)
iHigh = Format(iLow - (iLow * 0.25), "0.00")
oRng.Words(8).Text = ",0," & iHigh
oRng.InsertAfter ",0"
End If
Case Is = 9
If oRng.Words(6).Text = Chr(9) Then
oRng.Words(6).Text = ",0,"
oRng.InsertAfter ",0"
End If
If oRng.Words(8).Text = Chr(9) Then
oRng.Words(8).Text = ",0,"
oRng.InsertAfter ",0"
End If
Case Is = 11
If oRng.Words(8).Text = Chr(9) Then
oRng.Words(8).Text = ",0,"
oRng.InsertAfter ",0"
End If
Case Else
End Select
Next oPara
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Thank you for your help it worked a treat!
One more question...
Some of the lines in the list only have one entry i.e. first value
missing
Text (ROE)= 0.08 or second value missing Text (ROE)=0.05
Is it possible in word to add a value that is 25% higher (if the
second
value is missing) or 25% lower (if the first value is missing) based
upon
the only value on the line?
I suspect this is possible using excel but that I suppose is not a
question
for this group.
Thanks once again for your valuable help.
Dave
Change the search pattern to
(=[0-9.]{2,})[^032^0160^t]{2,}([0-9.]{2,})
i.e. you are looking for at least two digits and not three
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Hi Graham
Thanks for the prompt reply
I have tried the equation below and used the helpful website you
recommended. I have slightly modified the equation so that it can
do numbers above 9 and goes to three decimal places, so now it
looks like this:
(=[0-99.999]{3,})[^032^0160^t]{1,}([0-99.999]{3,})
\1,0,\2,0
And this is a typical section of the text I am trying to change.
Text (ROE)=0.04 0.06
Text (ROE)=0.04 0.06
Text (ROE)=0.04 0.07
Text (ROE)=0.05 0.07
Text (ROE)=0.05 0.07
Text (ROE)=0.05 0.08
Text (ROE)=0.05 0.08
Text (ROE)=0.05 0.08
Text (ROE)=0.05 0.08
Text (ROE)=0.05 0.08
Text (ROE)=8.4 9.2
Text (ROE)=11.5 13
Text (ROE)=19.5 22.5
Text (ROE)=20 23
When I use the replace function it works on some lines but not
others, so when I run it using the lines I have given as an example
it becomes:
Text (ROE)=0.04,0,0.06,0
Text (ROE)=0.04,0,0.06,0
Text (ROE)=0.04,0,0.07,0
Text (ROE)=0.05,0,0.07,0
Text (ROE)=0.05,0,0.07,0
Text (ROE)=0.05,0,0.08,0
Text (ROE)=0.05,0,0.08,0
Text (ROE)=0.05,0,0.08,0
Text (ROE)=0.05,0,0.08,0
Text (ROE)=0.05,0,0.08,0
Text (ROE)=8.4,0,9.2,0
Text (ROE)=11.5 13
Text (ROE)=19.5,0,22.5,0
Text (ROE)=20 23
Why has it ignored the two lines? Is it because there is a whole
number in the line or am I being particularly stupid and missing
something obvious in the equation?
Regards
Dave
You should be able to achieve that with the Replace function.
Replace
(=[0-9.]{3,})[^032^0160^t]{2,}([0-9.]{3,})
with
\1,0,\2,0
with the wildcard option set
See
http://www.gmayor.com/replace_using_wildcards.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Hi
Im new to visual basic so any help would be appreciated.
I need to alter the format of some text in a word document, it
goes something like this:
Original Text
text (123)=5.99 9.99
I need it to look like
text (123)=5.99,0,9.99,0
The values shown are not the same on every line
Two questions.
1. How do I insert the ...,0,...,0
2. How do I loop the macro so it repeats on every line to the end
of the document? (The documnet is about 12000 lines long).
Thanks for any help
Dave
--
--------------------------------- --- -- -
Posted with NewsLeecher v4.0 Beta 20
Web @
http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -