Microsoft Office Forums Could anyone fix the attached if statement. thx

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2015, 02:04 PM
Abacus1234 Abacus1234 is offline Could anyone fix the attached if statement. thx Windows Vista Could anyone fix the attached if statement. thx Office 2010 32bit
Novice
Could anyone fix the attached if statement. thx
 
Join Date: Nov 2011
Posts: 24
Abacus1234 is on a distinguished road
Default Could anyone fix the attached if statement. thx


I have attached word doc with if statement that I can't get right. Could anyone please troublrshoot.
Attached Files
File Type: docx mod.docx (10.4 KB, 5 views)
Reply With Quote
  #2  
Old 07-02-2015, 06:58 PM
macropod's Avatar
macropod macropod is offline Could anyone fix the attached if statement. thx Windows 7 64bit Could anyone fix the attached if statement. thx Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

You could use either:
{QUOTE"{SET Months {MERGEFIELD Loanmonths}}{=INT(Months/12) \# "0' year(s)'"} and {=MOD(Months,12) \# "0' month(s)'"}"}
for an output like:
# year(s) and # month(s)
or, somewhat more sophisticated:
{QUOTE"{SET Months {MERGEFIELD Loanmonths}}{=INT(Months/12)-1 \# "{=INT(Months/12) \# "0' years'"};;'1 year'"}{=(Months-INT(Months/12)*12)*(Months>12) \# "' and ';;"}{=MOD(Months,12)-1 \# "{=MOD(Months,12) \# "0' months'"};;'1 month'"}"}"}
for an output like:
1 month
2 months
1 year
2 years
1 year and 1 month
1 year and 2 months
2 years and 1 month
2 years and 2 months

For a macro to convert the above field code text representations to working field codes, See Convert Text Representations of Fields to Working Fields in the Mailmerge Tips and Tricks sticky thread (https://www.msofficeforums.com/mail-...ps-tricks.html) at the top of this forum.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 07-03-2015, 07:03 AM
Abacus1234 Abacus1234 is offline Could anyone fix the attached if statement. thx Windows Vista Could anyone fix the attached if statement. thx Office 2010 32bit
Novice
Could anyone fix the attached if statement. thx
 
Join Date: Nov 2011
Posts: 24
Abacus1234 is on a distinguished road
Default stuck on specific syntax for if statement in mergefield

Thanks for all the references. I need to know how to include the text "year(s)". Despite hours of searching through all references cannot find this specific syntax, and I have exhausted all ideas for guessing.

If you know this specific syntax, it would help me move on....

Thanks..

Does sticky code refer to the code in the mailmerge document? That is the only code I know.
Attached Files
File Type: doc syntax.doc (21.5 KB, 1 views)
Reply With Quote
  #4  
Old 07-03-2015, 07:14 AM
macropod's Avatar
macropod macropod is offline Could anyone fix the attached if statement. thx Windows 7 64bit Could anyone fix the attached if statement. thx Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

I already gave you that in the first example in my previous post:
{=INT(Months/12) \# "0' year(s)'"}
as part of the overall field or, if you prefer to have it as a stand-alone field:
{=INT({MERGEFIELD LoanMonths}/12) \# "0' year(s)'"}
or, to suppress the output for 0 years:
{=INT({MERGEFIELD LoanMonths}/12) \# "0' year(s)';;"}
Note that you can't use the \f switch in this context, as it applies only to the mergefield, not to any calculation based on it.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 07-03-2015, 08:39 AM
Abacus1234 Abacus1234 is offline Could anyone fix the attached if statement. thx Windows Vista Could anyone fix the attached if statement. thx Office 2010 32bit
Novice
Could anyone fix the attached if statement. thx
 
Join Date: Nov 2011
Posts: 24
Abacus1234 is on a distinguished road
Default Using your exact syntax adn still getting error on loan months

Hi Paul,
I have used your first example exactly, also tried with curly brackets and I still get syntax error on loanmonths.
Attached Files
File Type: doc syntax2.doc (22.0 KB, 1 views)
Reply With Quote
  #6  
Old 07-03-2015, 04:41 PM
macropod's Avatar
macropod macropod is offline Could anyone fix the attached if statement. thx Windows 7 64bit Could anyone fix the attached if statement. thx Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

The field code in your attachment isn't anything like the ones in my post.

Attached is your document with some demonstration fields (select & press F9 to use) and mergefields based on them. I've slightly simplified the field construction.
Attached Files
File Type: doc Loan Fields.doc (28.5 KB, 3 views)
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 07-04-2015, 05:10 AM
Abacus1234 Abacus1234 is offline Could anyone fix the attached if statement. thx Windows Vista Could anyone fix the attached if statement. thx Office 2010 32bit
Novice
Could anyone fix the attached if statement. thx
 
Join Date: Nov 2011
Posts: 24
Abacus1234 is on a distinguished road
Default

Hi Paul,
Thanks for all the help.
Could you look at this more finished version, and see why the If Statement itself is not working.
Attached Files
File Type: doc The first piece of the IF seems to be working.doc (23.0 KB, 1 views)
Reply With Quote
  #8  
Old 07-04-2015, 03:19 PM
macropod's Avatar
macropod macropod is offline Could anyone fix the attached if statement. thx Windows 7 64bit Could anyone fix the attached if statement. thx Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Try the attached. The field code is much simpler than what you're trying to do (and not an IF test in sight)!
Attached Files
File Type: doc Loan Fields 2.doc (24.0 KB, 7 views)
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #9  
Old 07-04-2015, 04:16 PM
Abacus1234 Abacus1234 is offline Could anyone fix the attached if statement. thx Windows Vista Could anyone fix the attached if statement. thx Office 2010 32bit
Novice
Could anyone fix the attached if statement. thx
 
Join Date: Nov 2011
Posts: 24
Abacus1234 is on a distinguished road
Default

That works perfectly. Thank-you for your help. I am at the end of a major project. It was a piece that needed to be done. I have never used Quote and Set before, so I will try to properly understand how and where to use it.
Reply With Quote
  #10  
Old 07-04-2015, 09:50 PM
macropod's Avatar
macropod macropod is offline Could anyone fix the attached if statement. thx Windows 7 64bit Could anyone fix the attached if statement. thx Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

The QUOTE field simply encompasses the remainder, making them easier to manage as a group and, more importantly in the mailmerge context, unlinks the others during the merge so you end up with only the results, not an active field.

The SET field creates a bookmark, named 'Loan' in the latest iteration, enabling that bookmark to be used in the main expression rather than having to repeat the MERGEFIELD for each component.

Far less transparent, however, is the main expression's construction. What I've done is to take advantage of the fact a numeric picture switch takes three parameters: - +ve;-ve;0 and I've leveraged those to hold secondary field expressions and text. In fact, I've even nested a tertiary set of fields inside the secondary field's numeric picture switch. This kind of thing isn't anything you're likely to find documented anywhere other than in my Microsoft Word Field Maths Tutorial, available at:
http://windowssecrets.com/forums/sho...Maths-Tutorial
or:
http://www.gmayor.com/downloads.htm#Third_party
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
One email with 2 photos attached won't load dijear Outlook 0 03-08-2015 07:48 PM
Could anyone fix the attached if statement. thx Please Help for VBA Code for Attached File.. krishnaoptif Word VBA 3 07-17-2012 12:29 AM
Removing Attached Mailboxes Hack Outlook 0 10-14-2011 06:09 AM
Open an attached email and sent does not work M_O_C Outlook 0 07-27-2011 09:36 AM
Could anyone fix the attached if statement. thx value attached to a name grilem2 Excel 3 04-15-2011 06:46 PM


All times are GMT -7. The time now is 03:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft