Table if a1 > a2 then

O

os

hallo,

in my word document i create a table (3x3).

i try to read out the cells and build an if then construct.

if a1 > a2 then a special character

is there somebody who can helb me with the code.

thanks.

BO
 
M

macropod

Hi OS,

To see how to do this and a wide range of other calculations in Word, check out my Word Field Maths Tutorial, at:
http://www.wopr.com/index.php?showtopic=365442
or
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the items titled 'Testing Or Returning Cell Contents In Tables' and 'Testing Or Returning Text Strings With
Logical Functions In Bookmarks'.

For your particular example, you could use a field coded as:
{IF{=A1}> {=A2} "Special Character" "Some other character"}
or
{IF{=A1-A2}> 0 "Special Character" "Some other character"}

Note: The field brace pairs (ie '{ }') for the above examples are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message.
 
O

os

hallo,

i need to do this in vba, because i need the operations later under
openoffice and also in ms office 2003/2007.

openoffice cant't do the field operration i needed.

0 > 10 % then print a special character
5 bis 10% then print a special character
5 bis -5% then print a special character
-5 bis -10% then print a special character
0 < -10% then print a special character

the special character should be an arrow (0 °, 45°, 90°, 135°, 180 ), to
show an development

thanks a lot
os


macropod said:
Hi OS,

To see how to do this and a wide range of other calculations in Word,
check out my Word Field Maths Tutorial, at:
http://www.wopr.com/index.php?showtopic=365442
or
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the items titled 'Testing Or Returning Cell
Contents In Tables' and 'Testing Or Returning Text Strings With Logical
Functions In Bookmarks'.

For your particular example, you could use a field coded as:
{IF{=A1}> {=A2} "Special Character" "Some other character"}
or
{IF{=A1-A2}> 0 "Special Character" "Some other character"}

Note: The field brace pairs (ie '{ }') for the above examples are created
via Ctrl-F9 - you can't simply type them or copy & paste them from this
message.


--
Cheers
macropod
[Microsoft MVP - Word]


os said:
hallo,

in my word document i create a table (3x3).

i try to read out the cells and build an if then construct.

if a1 > a2 then a special character

is there somebody who can helb me with the code.

thanks.

BO
 
M

macropod

Hi OS,

Here's some sample vba code:
Sub Demo()
Dim A1Val As String
Dim A2Val As String
Dim oRng As Range
With ThisDocument.Tables(1)
Set oRng = .Cell(1, 1).Range
oRng.MoveEnd Unit:=wdCharacter, Count:=-1
A1Val = oRng.Text
Set oRng = .Cell(2, 1).Range
oRng.MoveEnd Unit:=wdCharacter, Count:=-1
A2Val = oRng.Text
With .Cell(3, 1).Range
If A1Val > A2Val Then
.Text = "Special Character"
Else
.Text = "Other Character"
End If
End With
End With
End Sub

I'm not sure this will work with OpenOffice, however.

--
Cheers
macropod
[Microsoft MVP - Word]


os said:
hallo,

i need to do this in vba, because i need the operations later under openoffice and also in ms office 2003/2007.

openoffice cant't do the field operration i needed.

0 > 10 % then print a special character
5 bis 10% then print a special character
5 bis -5% then print a special character
-5 bis -10% then print a special character
0 < -10% then print a special character

the special character should be an arrow (0 °, 45°, 90°, 135°, 180 ), to show an development

thanks a lot
os


macropod said:
Hi OS,

To see how to do this and a wide range of other calculations in Word, check out my Word Field Maths Tutorial, at:
http://www.wopr.com/index.php?showtopic=365442
or
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the items titled 'Testing Or Returning Cell Contents In Tables' and 'Testing Or Returning Text Strings
With Logical Functions In Bookmarks'.

For your particular example, you could use a field coded as:
{IF{=A1}> {=A2} "Special Character" "Some other character"}
or
{IF{=A1-A2}> 0 "Special Character" "Some other character"}

Note: The field brace pairs (ie '{ }') for the above examples are created via Ctrl-F9 - you can't simply type them or copy &
paste them from this message.


--
Cheers
macropod
[Microsoft MVP - Word]


os said:
hallo,

in my word document i create a table (3x3).

i try to read out the cells and build an if then construct.

if a1 > a2 then a special character

is there somebody who can helb me with the code.

thanks.

BO
 

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