Excel Formats and IF

S

Sara

Hi there

I'm doing a mailmerge from an excel spreadsheet. It has a variety of time
values, dollar amounts, and rounding.
While I have worked out how to write the code to include the formatting, how
do I extend this so that blanks show as either nothing or N/A?
Time fields currently have this:
{ MERGEFIELD Mon_Start \@HH:mm }
Blank time fields are showing as "00:00" and I need them to be blank
Rounded fields currently have this:
{ MERGEFIELD Hourly_Rate \# "0.000000" }
Blank fields are showing as "0.000000" and I need them to be "N/A"
 
D

Doug Robbins - Word MVP

{ IF { MERGEFIELD Mon_Start \@HH:mm } = "00:00" " " { MERGEFIELD Mon_Start
\@HH:mm } }

{ IF { MERGEFIELD Hourly_Rate \# "0.000000" } = "0.000000" "N/A" {
MERGEFIELD Hourly_Rate \# "0.000000" } }

or

{ IF { MERGEFIELD Mon_Start } = "" " " { MERGEFIELD Mon_Start \@HH:mm } }

{ IF { MERGEFIELD Hourly_Rate } = "" "N/A" { MERGEFIELD Hourly_Rate \#
"0.000000" } }

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

A simpler alternative for the hourly rate format would be

{ Mergefield Hourly_Rate \# "0.00000;;N/A" }

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Sara

What am I doing wrong?

If I put this in:
{ IF { MERGEFIELD Mon_Start } = "" " " { MERGEFIELD Mon_Start \@HH:mm } }
The merge result is "Mon_Start" rather than the actual value from the
spreadsheet
If I put this in:
{ IF { MERGEFIELD Mon_Start \@HH:mm } = "00:00" " " { MERGEFIELD Mon_Start
\@HH:mm } }
The merge result is "Error! Too many picture switches defined"
 
G

Graham Mayor

Are you using CTRL+F9 for the field boundary pairs {} ?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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